From ab2b9d92ea35f67d580070d538168e60a2ce5d1e Mon Sep 17 00:00:00 2001 From: Artur Wojciechowski Date: Fri, 4 Nov 2022 14:19:29 +0100 Subject: [PATCH 01/63] feat: cucumber refactor --- .gitignore | 1 + cucumber.js | 11 + dist/web/pubnub.js | 71 +- dist/web/pubnub.min.js | 4 +- lib/core/components/_endpoint.js | 2 + lib/core/constants/operations.js | 72 +- lib/core/endpoints/memberships/add_members.js | 100 -- lib/core/endpoints/memberships/get_members.js | 73 -- .../endpoints/memberships/get_memberships.js | 73 -- lib/core/endpoints/memberships/join_spaces.js | 100 -- .../endpoints/memberships/leave_spaces.js | 96 -- .../endpoints/memberships/remove_members.js | 96 -- .../endpoints/memberships/update_members.js | 127 --- .../memberships/update_memberships.js | 127 --- lib/core/endpoints/objects/channel/channel.js | 2 - lib/core/endpoints/objects/member/member.js | 2 - .../objects/membership/membership.js | 2 - lib/core/endpoints/objects/uuid/uuid.js | 2 - lib/core/endpoints/spaces/create_space.js | 84 -- lib/core/endpoints/spaces/delete_space.js | 44 - lib/core/endpoints/spaces/get_space.js | 59 -- lib/core/endpoints/spaces/get_spaces.js | 64 -- lib/core/endpoints/spaces/update_space.js | 87 -- lib/core/endpoints/user/create.js | 40 + lib/core/endpoints/user/fetch.js | 34 + lib/core/endpoints/users/create_user.js | 84 -- lib/core/endpoints/users/delete_user.js | 44 - lib/core/endpoints/users/get_user.js | 59 -- lib/core/endpoints/users/get_users.js | 64 -- lib/core/endpoints/users/update_user.js | 87 -- lib/core/flow_interfaces.js | 31 - lib/core/pubnub-common.js | 6 +- lib/db/common.js | 15 - lib/db/web.js | 24 - lib/event-engine/dispatcher.js | 6 +- lib/event-engine/index.js | 6 +- lib/nativescript/index.js | 4 +- lib/node/index.js | 4 +- lib/react_native/index.js | 4 +- lib/titanium/index.js | 4 +- package-lock.json | 923 +++++++++++++++--- package.json | 16 +- src/core/components/_endpoint.ts | 24 + src/core/constants/operations.ts | 164 ++++ src/core/endpoints/user/create.ts | 40 + src/core/endpoints/user/fetch.ts | 32 + test/contract/definitions/grant.ts | 69 ++ test/contract/enums.ts | 15 - test/contract/parameter_types.ts | 17 - test/contract/setup.js | 11 + test/contract/shared/enums.ts | 37 + test/contract/shared/fixtures.ts | 8 + test/contract/shared/keysets.ts | 5 + test/contract/shared/pubnub.ts | 31 + test/contract/tsconfig.json | 19 +- test/{contract => old_contract}/cucumber.ts | 0 test/{contract => old_contract}/hooks.ts | 31 +- test/old_contract/parameter_types.ts | 14 + .../steps/access/auth.ts | 0 .../steps/access/grant_token.ts | 128 +-- .../steps/access/revoke_token.ts | 0 .../steps/common.ts | 0 .../steps/objectsv2/channel.ts | 0 .../steps/objectsv2/channel_member.ts | 0 .../steps/objectsv2/membership.ts | 0 .../steps/objectsv2/uuid.ts | 0 .../steps/subscribe/simple-subscribe.ts | 34 +- test/old_contract/tsconfig.json | 9 + test/{contract => old_contract}/utils.ts | 2 +- test/{contract => old_contract}/world.ts | 60 +- 70 files changed, 1627 insertions(+), 1877 deletions(-) create mode 100644 cucumber.js create mode 100644 lib/core/components/_endpoint.js delete mode 100644 lib/core/endpoints/memberships/add_members.js delete mode 100644 lib/core/endpoints/memberships/get_members.js delete mode 100644 lib/core/endpoints/memberships/get_memberships.js delete mode 100644 lib/core/endpoints/memberships/join_spaces.js delete mode 100644 lib/core/endpoints/memberships/leave_spaces.js delete mode 100644 lib/core/endpoints/memberships/remove_members.js delete mode 100644 lib/core/endpoints/memberships/update_members.js delete mode 100644 lib/core/endpoints/memberships/update_memberships.js delete mode 100644 lib/core/endpoints/objects/channel/channel.js delete mode 100644 lib/core/endpoints/objects/member/member.js delete mode 100644 lib/core/endpoints/objects/membership/membership.js delete mode 100644 lib/core/endpoints/objects/uuid/uuid.js delete mode 100644 lib/core/endpoints/spaces/create_space.js delete mode 100644 lib/core/endpoints/spaces/delete_space.js delete mode 100644 lib/core/endpoints/spaces/get_space.js delete mode 100644 lib/core/endpoints/spaces/get_spaces.js delete mode 100644 lib/core/endpoints/spaces/update_space.js create mode 100644 lib/core/endpoints/user/create.js create mode 100644 lib/core/endpoints/user/fetch.js delete mode 100644 lib/core/endpoints/users/create_user.js delete mode 100644 lib/core/endpoints/users/delete_user.js delete mode 100644 lib/core/endpoints/users/get_user.js delete mode 100644 lib/core/endpoints/users/get_users.js delete mode 100644 lib/core/endpoints/users/update_user.js delete mode 100644 lib/core/flow_interfaces.js delete mode 100644 lib/db/common.js delete mode 100644 lib/db/web.js create mode 100644 src/core/components/_endpoint.ts create mode 100644 src/core/constants/operations.ts create mode 100644 src/core/endpoints/user/create.ts create mode 100644 src/core/endpoints/user/fetch.ts create mode 100644 test/contract/definitions/grant.ts delete mode 100644 test/contract/enums.ts delete mode 100644 test/contract/parameter_types.ts create mode 100644 test/contract/setup.js create mode 100644 test/contract/shared/enums.ts create mode 100644 test/contract/shared/fixtures.ts create mode 100644 test/contract/shared/keysets.ts create mode 100644 test/contract/shared/pubnub.ts rename test/{contract => old_contract}/cucumber.ts (100%) rename test/{contract => old_contract}/hooks.ts (67%) create mode 100644 test/old_contract/parameter_types.ts rename test/{contract => old_contract}/steps/access/auth.ts (100%) rename test/{contract => old_contract}/steps/access/grant_token.ts (61%) rename test/{contract => old_contract}/steps/access/revoke_token.ts (100%) rename test/{contract => old_contract}/steps/common.ts (100%) rename test/{contract => old_contract}/steps/objectsv2/channel.ts (100%) rename test/{contract => old_contract}/steps/objectsv2/channel_member.ts (100%) rename test/{contract => old_contract}/steps/objectsv2/membership.ts (100%) rename test/{contract => old_contract}/steps/objectsv2/uuid.ts (100%) rename test/{contract => old_contract}/steps/subscribe/simple-subscribe.ts (65%) create mode 100644 test/old_contract/tsconfig.json rename test/{contract => old_contract}/utils.ts (79%) rename test/{contract => old_contract}/world.ts (54%) diff --git a/.gitignore b/.gitignore index 81d29bb35..7f2cc153c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ dist/titanium/stats.json dist/contract dist/cucumber upload +test/specs # GitHub Actions # ################## diff --git a/cucumber.js b/cucumber.js new file mode 100644 index 000000000..1bb853c25 --- /dev/null +++ b/cucumber.js @@ -0,0 +1,11 @@ +module.exports = { + default: [ + 'test/specs/features/**/*.feature', + '--require test/contract/setup.js', + '--require test/contract/definitions/**/*.ts', + '--format summary', + '--format progress-bar', + // '--format @cucumber/pretty-formatter', + '--publish-quiet', + ].join(' '), +}; diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index 7fe624271..5fcdb58bd 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -2332,7 +2332,68 @@ return default_1; }()); - /* */ + var Operation; + (function (Operation) { + Operation["Time"] = "PNTimeOperation"; + Operation["History"] = "PNHistoryOperation"; + Operation["DeleteMessages"] = "PNDeleteMessagesOperation"; + Operation["FetchMessages"] = "PNFetchMessagesOperation"; + Operation["MessageCounts"] = "PNMessageCountsOperation"; + Operation["Subscribe"] = "PNSubscribeOperation"; + Operation["Unsubscribe"] = "PNUnsubscribeOperation"; + Operation["Publish"] = "PNPublishOperation"; + Operation["Signal"] = "PNSignalOperation"; + Operation["AddMessageAction"] = "PNAddActionOperation"; + Operation["RemoveMessageAction"] = "PNRemoveMessageActionOperation"; + Operation["GetMessageActions"] = "PNGetMessageActionsOperation"; + Operation["CreateUser"] = "PNCreateUserOperation"; + Operation["UpdateUser"] = "PNUpdateUserOperation"; + Operation["RemoveUser"] = "PNRemoveUserOperation"; + Operation["FetchUser"] = "PNFetchUserOperation"; + Operation["GetUsers"] = "PNGetUsersOperation"; + Operation["CreateSpace"] = "PNCreateSpaceOperation"; + Operation["UpdateSpace"] = "PNUpdateSpaceOperation"; + Operation["RemoveSpace"] = "PNRemoveSpaceOperation"; + Operation["FetchSpace"] = "PNFetchSpaceOperation"; + Operation["GetSpaces"] = "PNGetSpacesOperation"; + Operation["GetMembers"] = "PNGetMembersOperation"; + Operation["UpdateMembers"] = "PNUpdateMembersOperation"; + Operation["GetMemberships"] = "PNGetMembershipsOperation"; + Operation["UpdateMemberships"] = "PNUpdateMembershipsOperation"; + Operation["ListFiles"] = "PNListFilesOperation"; + Operation["GenerateUploadUrl"] = "PNGenerateUploadUrlOperation"; + Operation["PublishFile"] = "PNPublishFileOperation"; + Operation["GetFileUrl"] = "PNGetFileUrlOperation"; + Operation["DownloadFile"] = "PNDownloadFileOperation"; + Operation["GetAllUUIDMetadata"] = "PNGetAllUUIDMetadataOperation"; + Operation["GetUUIDMetadata"] = "PNGetUUIDMetadataOperation"; + Operation["SetUUIDMetadata"] = "PNSetUUIDMetadataOperation"; + Operation["RemoveUUIDMetadata"] = "PNRemoveUUIDMetadataOperation"; + Operation["GetAllChannelMetadata"] = "PNGetAllChannelMetadataOperation"; + Operation["GetChannelMetadata"] = "PNGetChannelMetadataOperation"; + Operation["SetChannelMetadata"] = "PNSetChannelMetadataOperation"; + Operation["RemoveChannelMetadata"] = "PNRemoveChannelMetadataOperation"; + Operation["SetMembers"] = "PNSetMembersOperation"; + Operation["SetMemberships"] = "PNSetMembershipsOperation"; + Operation["PushNotificationEnabledChannels"] = "PNPushNotificationEnabledChannelsOperation"; + Operation["RemoveAllPushNotifications"] = "PNRemoveAllPushNotificationsOperation"; + Operation["WhereNow"] = "PNWhereNowOperation"; + Operation["SetState"] = "PNSetStateOperation"; + Operation["HereNow"] = "PNHereNowOperation"; + Operation["GetState"] = "PNGetStateOperation"; + Operation["Heartbeat"] = "PNHeartbeatOperation"; + Operation["ChannelGroups"] = "PNChannelGroupsOperation"; + Operation["RemoveGroup"] = "PNRemoveGroupOperation"; + Operation["ChannelsForGroup"] = "PNChannelsForGroupOperation"; + Operation["AddChannelsToGroup"] = "PNAddChannelsToGroupOperation"; + Operation["RemoveChannelsFromGroup"] = "PNRemoveChannelsFromGroupOperation"; + Operation["AccessManagerGrant"] = "PNAccessManagerGrant"; + Operation["AccessManagerGrantToken"] = "PNAccessManagerGrantToken"; + Operation["AccessManagerAudit"] = "PNAccessManagerAudit"; + Operation["AccessManagerRevokeToken"] = "PNAccessManagerRevokeToken"; + Operation["Handshake"] = "PNHandshakeOperation"; + Operation["ReceiveMessages"] = "PNReceiveMessagesOperation"; + })(Operation || (Operation = {})); var OPERATIONS = { PNTimeOperation: 'PNTimeOperation', PNHistoryOperation: 'PNHistoryOperation', @@ -2351,13 +2412,13 @@ // Objects API PNCreateUserOperation: 'PNCreateUserOperation', PNUpdateUserOperation: 'PNUpdateUserOperation', - PNDeleteUserOperation: 'PNDeleteUserOperation', - PNGetUserOperation: 'PNGetUsersOperation', + PNRemoveUserOperation: 'PNRemoveUserOperation', + PNFetchUserOperation: 'PNFetchUserOperation', PNGetUsersOperation: 'PNGetUsersOperation', PNCreateSpaceOperation: 'PNCreateSpaceOperation', PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', - PNDeleteSpaceOperation: 'PNDeleteSpaceOperation', - PNGetSpaceOperation: 'PNGetSpacesOperation', + PNRemoveSpaceOperation: 'PNRemoveSpaceOperation', + PNFetchSpaceOperation: 'PNFetchSpaceOperation', PNGetSpacesOperation: 'PNGetSpacesOperation', PNGetMembersOperation: 'PNGetMembersOperation', PNUpdateMembersOperation: 'PNUpdateMembersOperation', diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index f84d196ad..755940dfa 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var b=function e(){var i,h,b=l(),v=b>>5,m=31&b;if(7===v)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(v<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(v))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var T;if(h<0)for(T=[];!f();)T.push(e());else for(T=new Array(h),i=0;i0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var b=function e(){var i,h,b=l(),v=b>>5,m=31&b;if(7===v)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(v<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(v))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var N;if(h<0)for(N=[];!f();)N.push(e());else for(N=new Array(h),i=0;i=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.1"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var b,v,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),v=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=v.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],b=e[o+9],v=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],N=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,N,k,a,12,c[1]),k=t(k,T,w,N,l,17,c[2]),N=t(N,k,T,w,p,22,c[3]);w=t(w,N,k,T,h,7,c[4]),T=t(T,w,N,k,f,12,c[5]),k=t(k,T,w,N,d,17,c[6]),N=t(N,k,T,w,g,22,c[7]),w=t(w,N,k,T,y,7,c[8]),T=t(T,w,N,k,b,12,c[9]),k=t(k,T,w,N,v,17,c[10]),N=t(N,k,T,w,m,22,c[11]),w=t(w,N,k,T,_,7,c[12]),T=t(T,w,N,k,O,12,c[13]),k=t(k,T,w,N,P,17,c[14]),w=n(w,N=t(N,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,N,k,d,9,c[17]),k=n(k,T,w,N,m,14,c[18]),N=n(N,k,T,w,u,20,c[19]),w=n(w,N,k,T,f,5,c[20]),T=n(T,w,N,k,v,9,c[21]),k=n(k,T,w,N,S,14,c[22]),N=n(N,k,T,w,h,20,c[23]),w=n(w,N,k,T,b,5,c[24]),T=n(T,w,N,k,P,9,c[25]),k=n(k,T,w,N,p,14,c[26]),N=n(N,k,T,w,y,20,c[27]),w=n(w,N,k,T,O,5,c[28]),T=n(T,w,N,k,l,9,c[29]),k=n(k,T,w,N,g,14,c[30]),w=r(w,N=n(N,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,N,k,y,11,c[33]),k=r(k,T,w,N,m,16,c[34]),N=r(N,k,T,w,P,23,c[35]),w=r(w,N,k,T,a,4,c[36]),T=r(T,w,N,k,h,11,c[37]),k=r(k,T,w,N,g,16,c[38]),N=r(N,k,T,w,v,23,c[39]),w=r(w,N,k,T,O,4,c[40]),T=r(T,w,N,k,u,11,c[41]),k=r(k,T,w,N,p,16,c[42]),N=r(N,k,T,w,d,23,c[43]),w=r(w,N,k,T,b,4,c[44]),T=r(T,w,N,k,_,11,c[45]),k=r(k,T,w,N,S,16,c[46]),w=i(w,N=r(N,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,N,k,g,10,c[49]),k=i(k,T,w,N,P,15,c[50]),N=i(N,k,T,w,f,21,c[51]),w=i(w,N,k,T,_,6,c[52]),T=i(T,w,N,k,p,10,c[53]),k=i(k,T,w,N,v,15,c[54]),N=i(N,k,T,w,a,21,c[55]),w=i(w,N,k,T,y,6,c[56]),T=i(T,w,N,k,S,10,c[57]),k=i(k,T,w,N,d,15,c[58]),N=i(N,k,T,w,O,21,c[59]),w=i(w,N,k,T,h,6,c[60]),T=i(T,w,N,k,m,10,c[61]),k=i(k,T,w,N,l,15,c[62]),N=i(N,k,T,w,b,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+N|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var b=(b=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&b^99;r[g]=b,i[b]=g;var v=f[g],m=f[v],_=f[m],O=257*f[b]^16843008*b;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*v^16843008*g,c[b]=O<<24|O>>>8,l[b]=O<<16|O>>>16,p[b]=O<<8|O>>>24,h[b]=O,g?(g=v^f[f[f[_^v]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],b=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=b}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],b=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=b,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function C(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function E(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return E(e).map((function(t){return"".concat(t,"=").concat(C(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:C},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},j=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new N({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),R={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==R.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==R.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case R.PNPublishOperation:t="pub";break;case R.PNSignalOperation:t="sig";break;case R.PNHistoryOperation:case R.PNFetchMessagesOperation:case R.PNDeleteMessagesOperation:case R.PNMessageCounts:t="hist";break;case R.PNUnsubscribeOperation:case R.PNWhereNowOperation:case R.PNHereNowOperation:case R.PNHeartbeatOperation:case R.PNSetStateOperation:case R.PNGetStateOperation:t="pres";break;case R.PNAddChannelsToGroupOperation:case R.PNRemoveChannelsFromGroupOperation:case R.PNChannelGroupsOperation:case R.PNRemoveGroupOperation:case R.PNChannelsForGroupOperation:t="cg";break;case R.PNPushNotificationEnabledChannelsOperation:case R.PNRemoveAllPushNotificationsOperation:t="push";break;case R.PNCreateUserOperation:case R.PNUpdateUserOperation:case R.PNDeleteUserOperation:case R.PNGetUserOperation:case R.PNGetUsersOperation:case R.PNCreateSpaceOperation:case R.PNUpdateSpaceOperation:case R.PNDeleteSpaceOperation:case R.PNGetSpaceOperation:case R.PNGetSpacesOperation:case R.PNGetMembersOperation:case R.PNUpdateMembersOperation:case R.PNGetMembershipsOperation:case R.PNUpdateMembershipsOperation:t="obj";break;case R.PNAddMessageActionOperation:case R.PNRemoveMessageActionOperation:case R.PNGetMessageActionsOperation:t="msga";break;case R.PNAccessManagerGrant:case R.PNAccessManagerAudit:t="pam";break;case R.PNAccessManagerGrantToken:case R.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function W(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return R.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return R.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return R.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return R.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return R.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return R.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return R.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return R.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,b,v,m,_,O,P,S,w,T,k,N,C,E,A,M,j,R,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,b=i.url,v=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=v,e.mimeType&&(P=v.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,20]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[b,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(C=(N=l).POSTFILE,E=[b,P],[4,e.toFile()]):[3,10];case 8:return[4,C.apply(N,E.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,j=[b,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,j.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(R=l).POSTFILE,x=[b,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(R,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,20];case 18:return I=o.sent(),[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=21;case 21:return o.trys.push([21,23,,24]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 22:return L=o.sent(),F=!0,[3,24];case 23:return o.sent(),K-=1,[3,24];case 24:if(!F&&K>0)return[3,21];o.label=25;case 25:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var a="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),u={};u.uuid=o.getUUID(),u.pnsdk=z(o),o.getAuthKey()&&(u.auth=o.getAuthKey()),o.secretKey&&J(e,a,u,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var c=Object.keys(u).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(u[e]))})).join("&");return""!==c?"".concat(s.getStandardOrigin()).concat(a,"?").concat(c):"".concat(s.getStandardOrigin()).concat(a)},ve={getOperation:function(){return R.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return R.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return R.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return R.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return R.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return R.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return R.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return R.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return R.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return R.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ee={getOperation:function(){return R.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return R.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return R.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var je=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var Re=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,b=t.join,v=void 0!==b&&b,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=v?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return R.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return R.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return R.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return R.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return R.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return R.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return R.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return R.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var We=Object.freeze({__proto__:null,getOperation:function(){return R.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Xe={getOperation:function(){return R.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return R.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var b=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:b,fromContext:v,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&console.log(e),[2]}))}))}))),r.on(ft.type,ct((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Ct())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Nt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(dt.type,ct((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r.metadata))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(gt.type,(function(e,t){return Mt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(bt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("HANDSHAKE_FAILURE");jt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),jt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Rt=new Ye("STOPPED");Rt.on(gt.type,(function(e,t){return Rt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(bt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Et.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ft(e)})),xt.onExit((function(){return ft.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),xt.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Ct.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason})})),xt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return pt.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[ht(t.payload.events)])})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),Dt.on(Nt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Ct.type,(function(e){return jt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return lt(e.channels,e.groups)})),Gt.onExit((function(){return lt.cancel})),Gt.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(vt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(gt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(gt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(bt())},e.prototype.disconnect=function(){this.engine.transition(yt())},e}(),Lt=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new g({setup:e});this._config=o;var s=new T({config:o}),c=e.cryptography;r.init(o);var l=new L(o,i);this._tokenManager=l;var p=new U({maximumSamplesCount:6e4});this._telemetryManager=p;var h={config:o,networking:r,crypto:s,cryptography:c,tokenManager:l,telemetryManager:p,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return c.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return c.decryptFile(e,n,t.File)};var f=W.bind(this,h,Je),d=W.bind(this,h,ie),y=W.bind(this,h,se),b=W.bind(this,h,ue),v=W.bind(this,h,We),m=new F;if(this._listenerManager=m,this.iAmHere=W.bind(this,h,se),this.iAmAway=W.bind(this,h,ie),this.setPresenceState=W.bind(this,h,ue),this.handshake=W.bind(this,h,Xe),this.receiveMessages=W.bind(this,h,$e),!0===o.enableSubscribeBeta){var _=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages});this.subscribe=_.subscribe.bind(_),this.unsubscribe=_.unsubscribe.bind(_),this.eventEngine=_}else{var O=new j({timeEndpoint:f,leaveEndpoint:d,heartbeatEndpoint:y,setStateEndpoint:b,subscribeEndpoint:v,crypto:h.crypto,config:h.config,listenerManager:m,getFileUrl:function(e){return be(h,e)}});this.subscribe=O.adaptSubscribeChange.bind(O),this.unsubscribe=O.adaptUnsubscribeChange.bind(O),this.disconnect=O.disconnect.bind(O),this.reconnect=O.reconnect.bind(O),this.unsubscribeAll=O.unsubscribeAll.bind(O),this.getSubscribedChannels=O.getSubscribedChannels.bind(O),this.getSubscribedChannelGroups=O.getSubscribedChannelGroups.bind(O),this.setState=O.adaptStateChange.bind(O),this.presence=O.adaptPresenceChange.bind(O),this.destroy=function(e){O.unsubscribeAll(e),O.disconnect()}}this.addListener=m.addListener.bind(m),this.removeListener=m.removeListener.bind(m),this.removeAllListeners=m.removeAllListeners.bind(m),this.parseToken=l.parseToken.bind(l),this.setToken=l.setToken.bind(l),this.getToken=l.getToken.bind(l),this.channelGroups={listGroups:W.bind(this,h,Y),listChannels:W.bind(this,h,Z),addChannels:W.bind(this,h,X),removeChannels:W.bind(this,h,$),deleteGroup:W.bind(this,h,Q)},this.push={addChannels:W.bind(this,h,ee),removeChannels:W.bind(this,h,te),deleteDevice:W.bind(this,h,re),listChannels:W.bind(this,h,ne)},this.hereNow=W.bind(this,h,ce),this.whereNow=W.bind(this,h,oe),this.getState=W.bind(this,h,ae),this.grant=W.bind(this,h,Re),this.grantToken=W.bind(this,h,De),this.audit=W.bind(this,h,je),this.revokeToken=W.bind(this,h,Ge),this.publish=W.bind(this,h,Fe),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=W.bind(this,h,Le),this.history=W.bind(this,h,He),this.deleteMessages=W.bind(this,h,qe),this.messageCounts=W.bind(this,h,ze),this.fetchMessages=W.bind(this,h,Ve),this.addMessageAction=W.bind(this,h,le),this.removeMessageAction=W.bind(this,h,pe),this.getMessageActions=W.bind(this,h,he),this.listFiles=W.bind(this,h,fe);var P=W.bind(this,h,de);this.publishFile=W.bind(this,h,ge),this.sendFile=ye({generateUploadUrl:P,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return be(h,e)},this.downloadFile=W.bind(this,h,ve),this.deleteFile=W.bind(this,h,me),this.objects={getAllUUIDMetadata:W.bind(this,h,_e),getUUIDMetadata:W.bind(this,h,Oe),setUUIDMetadata:W.bind(this,h,Pe),removeUUIDMetadata:W.bind(this,h,Se),getAllChannelMetadata:W.bind(this,h,we),getChannelMetadata:W.bind(this,h,Te),setChannelMetadata:W.bind(this,h,ke),removeChannelMetadata:W.bind(this,h,Ne),getChannelMembers:W.bind(this,h,Ce),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function Ht(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?Ht(s):s})),n}var qt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),zt={exports:{}},Vt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function rn(e,t,n,r){void 0===r&&(r=Yt());var i,o=on(e,"",0,[],void 0,0,r)||e;try{i=0===Qt.length?JSON.stringify(o,t,n):JSON.stringify(o,sn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==$t.length;){var s=$t.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function on(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(fn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===pn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=dn[u]:u<2048?s+=dn[192|u>>6]+dn[128|63&u]:u<55296||u>=57344?s+=dn[224|u>>12]+dn[128|u>>6&63]+dn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=dn[240|u>>18]+dn[128|u>>12&63]+dn[128|u>>6&63]+dn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(fn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(On(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},xn=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&An.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},In={formats:ln,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||En.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Mn(l)?[l]:l),An.call(r,c)?r[c]=En.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Dn(e){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dn(e)}var Gn=function(e){return null!==e&&"object"===Dn(e)};function Kn(e){return Kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kn(e)}var Fn=Gn,Ln=Bn;function Bn(e){if(e)return function(e){for(var t in Bn.prototype)Object.prototype.hasOwnProperty.call(Bn.prototype,t)&&(e[t]=Bn.prototype[t]);return e}(e)}Bn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Bn.prototype.parse=function(e){return this._parser=e,this},Bn.prototype.responseType=function(e){return this._responseType=e,this},Bn.prototype.serialize=function(e){return this._serializer=e,this},Bn.prototype.timeout=function(e){if(!e||"object"!==Kn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Bn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var Hn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),qn=new Set([408,413,429,500,502,503,504,521,522,524]);Bn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&qn.has(t.status))return!0;if(e){if(e.code&&Hn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Bn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Bn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Bn.prototype.catch=function(e){return this.then(void 0,e)},Bn.prototype.use=function(e){return e(this),this},Bn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Bn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Bn.prototype.get=function(e){return this._header[e.toLowerCase()]},Bn.prototype.getHeader=Bn.prototype.get,Bn.prototype.set=function(e,t){if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Bn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Bn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Bn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Bn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Bn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Bn.prototype.redirects=function(e){return this._maxRedirects=e,this},Bn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Bn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Bn.prototype.send=function(e){var t=Fn(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Fn(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Bn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Bn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Bn.prototype._appendQueryString=function(){console.warn("Unsupported")},Bn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Bn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var zn={};function Vn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},v.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=v,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(zt,zt.exports);var tr=zt.exports;function nr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function rr(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(nr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function ir(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=tr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function or(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function sr(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function ar(e,t,n,r){var i=tr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function ur(e,t,n,r){var i=tr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function cr(e,t,n){var r=tr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function lr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var pr,hr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=lr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=lr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),fr=(pr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),pr.supportsFile="undefined"!=typeof File,pr.supportsBlob="undefined"!=typeof Blob,pr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,pr.supportsBuffer=!1,pr.supportsStream=!1,pr.supportsString=!0,pr.supportsEncryptFile=!0,pr.supportsFileUri=!1,pr);function dr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var gr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Bt({del:cr,get:sr,post:ar,patch:ur,sendBeacon:dr,getfile:or,postfile:ir}),t.cbor=new qt((function(e){return Ht(p.decode(e))}),y),t.PubNubFile=fr,t.cryptography=new hr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Lt);return gr})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 i(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=i,r.VERSION=t,e.uuid=r,e.isUUID=i}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var f,d,g,y,b,v=h.exports,m=function(){return v.uuid?v.uuid():v()},_=function(){function e(e){var t,n,r,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(m()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.setCipherKey(i.cipherKey),this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableSubscribeBeta=null!==(r=i.enableSubscribeBeta)&&void 0!==r&&r,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e){return this.cipherKey=e,this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.0"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}(),O=O||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),d=(f=O).enc.Utf8,f.algo.HMAC=f.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=d.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return y.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=O,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],b=e[o+9],v=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],k=s[1],T=s[2],N=s[3],u,7,c[0]),N=t(N,w,k,T,a,12,c[1]),T=t(T,N,w,k,l,17,c[2]),k=t(k,T,N,w,p,22,c[3]);w=t(w,k,T,N,h,7,c[4]),N=t(N,w,k,T,f,12,c[5]),T=t(T,N,w,k,d,17,c[6]),k=t(k,T,N,w,g,22,c[7]),w=t(w,k,T,N,y,7,c[8]),N=t(N,w,k,T,b,12,c[9]),T=t(T,N,w,k,v,17,c[10]),k=t(k,T,N,w,m,22,c[11]),w=t(w,k,T,N,_,7,c[12]),N=t(N,w,k,T,O,12,c[13]),T=t(T,N,w,k,P,17,c[14]),w=n(w,k=t(k,T,N,w,S,22,c[15]),T,N,a,5,c[16]),N=n(N,w,k,T,d,9,c[17]),T=n(T,N,w,k,m,14,c[18]),k=n(k,T,N,w,u,20,c[19]),w=n(w,k,T,N,f,5,c[20]),N=n(N,w,k,T,v,9,c[21]),T=n(T,N,w,k,S,14,c[22]),k=n(k,T,N,w,h,20,c[23]),w=n(w,k,T,N,b,5,c[24]),N=n(N,w,k,T,P,9,c[25]),T=n(T,N,w,k,p,14,c[26]),k=n(k,T,N,w,y,20,c[27]),w=n(w,k,T,N,O,5,c[28]),N=n(N,w,k,T,l,9,c[29]),T=n(T,N,w,k,g,14,c[30]),w=r(w,k=n(k,T,N,w,_,20,c[31]),T,N,f,4,c[32]),N=r(N,w,k,T,y,11,c[33]),T=r(T,N,w,k,m,16,c[34]),k=r(k,T,N,w,P,23,c[35]),w=r(w,k,T,N,a,4,c[36]),N=r(N,w,k,T,h,11,c[37]),T=r(T,N,w,k,g,16,c[38]),k=r(k,T,N,w,v,23,c[39]),w=r(w,k,T,N,O,4,c[40]),N=r(N,w,k,T,u,11,c[41]),T=r(T,N,w,k,p,16,c[42]),k=r(k,T,N,w,d,23,c[43]),w=r(w,k,T,N,b,4,c[44]),N=r(N,w,k,T,_,11,c[45]),T=r(T,N,w,k,S,16,c[46]),w=i(w,k=r(k,T,N,w,l,23,c[47]),T,N,u,6,c[48]),N=i(N,w,k,T,g,10,c[49]),T=i(T,N,w,k,P,15,c[50]),k=i(k,T,N,w,f,21,c[51]),w=i(w,k,T,N,_,6,c[52]),N=i(N,w,k,T,p,10,c[53]),T=i(T,N,w,k,v,15,c[54]),k=i(k,T,N,w,a,21,c[55]),w=i(w,k,T,N,y,6,c[56]),N=i(N,w,k,T,S,10,c[57]),T=i(T,N,w,k,d,15,c[58]),k=i(k,T,N,w,O,21,c[59]),w=i(w,k,T,N,h,6,c[60]),N=i(N,w,k,T,m,10,c[61]),T=i(T,N,w,k,l,15,c[62]),k=i(k,T,N,w,b,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+k|0,s[2]=s[2]+T|0,s[3]=s[3]+N|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=O,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=O,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var b=(b=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&b^99;r[g]=b,i[b]=g;var v=f[g],m=f[v],_=f[m],P=257*f[b]^16843008*b;o[g]=P<<24|P>>>8,s[g]=P<<16|P>>>16,a[g]=P<<8|P>>>24,u[g]=P,P=16843009*_^65537*m^257*v^16843008*g,c[b]=P<<24|P>>>8,l[b]=P<<16|P>>>16,p[b]=P<<8|P>>>24,h[b]=P,g?(g=v^f[f[f[_^v]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],b=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=b}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],b=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=b,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),O.mode.ECB=((b=O.lib.BlockCipherMode.extend()).Encryptor=b.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),b.Decryptor=b.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),b);var P=O;function S(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function k(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function C(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var E,A={signPamFromParams:function(e){return C(e).map((function(t){return"".concat(t,"=").concat(k(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:k},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},U=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new N({timeEndpoint:o}),this._dedupingManager=new T({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}();!function(e){e.Time="PNTimeOperation",e.History="PNHistoryOperation",e.DeleteMessages="PNDeleteMessagesOperation",e.FetchMessages="PNFetchMessagesOperation",e.MessageCounts="PNMessageCountsOperation",e.Subscribe="PNSubscribeOperation",e.Unsubscribe="PNUnsubscribeOperation",e.Publish="PNPublishOperation",e.Signal="PNSignalOperation",e.AddMessageAction="PNAddActionOperation",e.RemoveMessageAction="PNRemoveMessageActionOperation",e.GetMessageActions="PNGetMessageActionsOperation",e.CreateUser="PNCreateUserOperation",e.UpdateUser="PNUpdateUserOperation",e.RemoveUser="PNRemoveUserOperation",e.FetchUser="PNFetchUserOperation",e.GetUsers="PNGetUsersOperation",e.CreateSpace="PNCreateSpaceOperation",e.UpdateSpace="PNUpdateSpaceOperation",e.RemoveSpace="PNRemoveSpaceOperation",e.FetchSpace="PNFetchSpaceOperation",e.GetSpaces="PNGetSpacesOperation",e.GetMembers="PNGetMembersOperation",e.UpdateMembers="PNUpdateMembersOperation",e.GetMemberships="PNGetMembershipsOperation",e.UpdateMemberships="PNUpdateMembershipsOperation",e.ListFiles="PNListFilesOperation",e.GenerateUploadUrl="PNGenerateUploadUrlOperation",e.PublishFile="PNPublishFileOperation",e.GetFileUrl="PNGetFileUrlOperation",e.DownloadFile="PNDownloadFileOperation",e.GetAllUUIDMetadata="PNGetAllUUIDMetadataOperation",e.GetUUIDMetadata="PNGetUUIDMetadataOperation",e.SetUUIDMetadata="PNSetUUIDMetadataOperation",e.RemoveUUIDMetadata="PNRemoveUUIDMetadataOperation",e.GetAllChannelMetadata="PNGetAllChannelMetadataOperation",e.GetChannelMetadata="PNGetChannelMetadataOperation",e.SetChannelMetadata="PNSetChannelMetadataOperation",e.RemoveChannelMetadata="PNRemoveChannelMetadataOperation",e.SetMembers="PNSetMembersOperation",e.SetMemberships="PNSetMembershipsOperation",e.PushNotificationEnabledChannels="PNPushNotificationEnabledChannelsOperation",e.RemoveAllPushNotifications="PNRemoveAllPushNotificationsOperation",e.WhereNow="PNWhereNowOperation",e.SetState="PNSetStateOperation",e.HereNow="PNHereNowOperation",e.GetState="PNGetStateOperation",e.Heartbeat="PNHeartbeatOperation",e.ChannelGroups="PNChannelGroupsOperation",e.RemoveGroup="PNRemoveGroupOperation",e.ChannelsForGroup="PNChannelsForGroupOperation",e.AddChannelsToGroup="PNAddChannelsToGroupOperation",e.RemoveChannelsFromGroup="PNRemoveChannelsFromGroupOperation",e.AccessManagerGrant="PNAccessManagerGrant",e.AccessManagerGrantToken="PNAccessManagerGrantToken",e.AccessManagerAudit="PNAccessManagerAudit",e.AccessManagerRevokeToken="PNAccessManagerRevokeToken",e.Handshake="PNHandshakeOperation",e.ReceiveMessages="PNReceiveMessagesOperation"}(E||(E={}));var R={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNRemoveUserOperation:"PNRemoveUserOperation",PNFetchUserOperation:"PNFetchUserOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNRemoveSpaceOperation:"PNRemoveSpaceOperation",PNFetchSpaceOperation:"PNFetchSpaceOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},j=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==R.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==R.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case R.PNPublishOperation:t="pub";break;case R.PNSignalOperation:t="sig";break;case R.PNHistoryOperation:case R.PNFetchMessagesOperation:case R.PNDeleteMessagesOperation:case R.PNMessageCounts:t="hist";break;case R.PNUnsubscribeOperation:case R.PNWhereNowOperation:case R.PNHereNowOperation:case R.PNHeartbeatOperation:case R.PNSetStateOperation:case R.PNGetStateOperation:t="pres";break;case R.PNAddChannelsToGroupOperation:case R.PNRemoveChannelsFromGroupOperation:case R.PNChannelGroupsOperation:case R.PNRemoveGroupOperation:case R.PNChannelsForGroupOperation:t="cg";break;case R.PNPushNotificationEnabledChannelsOperation:case R.PNRemoveAllPushNotificationsOperation:t="push";break;case R.PNCreateUserOperation:case R.PNUpdateUserOperation:case R.PNDeleteUserOperation:case R.PNGetUserOperation:case R.PNGetUsersOperation:case R.PNCreateSpaceOperation:case R.PNUpdateSpaceOperation:case R.PNDeleteSpaceOperation:case R.PNGetSpaceOperation:case R.PNGetSpacesOperation:case R.PNGetMembersOperation:case R.PNUpdateMembersOperation:case R.PNGetMembershipsOperation:case R.PNUpdateMembershipsOperation:t="obj";break;case R.PNAddMessageActionOperation:case R.PNRemoveMessageActionOperation:case R.PNGetMessageActionsOperation:t="msga";break;case R.PNAccessManagerGrant:case R.PNAccessManagerAudit:t="pam";break;case R.PNAccessManagerGrantToken:case R.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),F=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),K=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),H=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function B(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function W(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return R.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return R.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return R.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return R.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return R.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return R.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return R.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return R.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,b,v,m,_,O,P,S,w,N,T,k,C,E,A,M,U,R,j,x,I,D,G,F,K,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new H("Validation failed, check status for details",B("channel can't be empty"));if(!p)throw new H("Validation failed, check status for details",B("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,b=i.url,v=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=v,e.mimeType&&(P=v.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,20]),a.supportsFileUri&&p.uri?(N=(w=l).POSTFILE,T=[b,P],[4,e.toFileUri()]):[3,7];case 5:return[4,N.apply(w,T.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(C=(k=l).POSTFILE,E=[b,P],[4,e.toFile()]):[3,10];case 8:return[4,C.apply(k,E.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,U=[b,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,U.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(j=(R=l).POSTFILE,x=[b,P],[4,e.toBlob()]):[3,16];case 14:return[4,j.apply(R,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,20];case 18:return I=o.sent(),[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new H(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:if(204!==S.status)throw new H("Upload to bucket was unsuccessful",S);F=u.fileUploadPublishRetryLimit,K=!1,L={timetoken:"0"},o.label=21;case 21:return o.trys.push([21,23,,24]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 22:return L=o.sent(),K=!0,[3,24];case 23:return o.sent(),F-=1,[3,24];case 24:if(!K&&F>0)return[3,21];o.label=25;case 25:if(K)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new H("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking;if(!n)throw new H("Validation failed, check status for details",B("channel can't be empty"));if(!r)throw new H("Validation failed, check status for details",B("file id can't be empty"));if(!i)throw new H("Validation failed, check status for details",B("file name can't be empty"));var a="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),u={};u.uuid=o.getUUID(),u.pnsdk=z(o),o.getAuthKey()&&(u.auth=o.getAuthKey()),o.secretKey&&J(e,a,u,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var c=Object.keys(u).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(u[e]))})).join("&");return""!==c?"".concat(s.getStandardOrigin()).concat(a,"?").concat(c):"".concat(s.getStandardOrigin()).concat(a)},ve={getOperation:function(){return R.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return R.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return R.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return R.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return R.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return R.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ne={getOperation:function(){return R.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return R.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return R.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return R.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ee={getOperation:function(){return R.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return R.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return R.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Ue=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var Re=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,b=t.join,v=void 0!==b&&b,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=v?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function je(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(je(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return je(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return R.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Fe(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Ke=Object.freeze({__proto__:null,getOperation:function(){return R.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Fe(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Fe(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return R.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function He(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var Be=Object.freeze({__proto__:null,getOperation:function(){return R.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:He(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return R.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return R.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return R.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return R.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var We=Object.freeze({__proto__:null,getOperation:function(){return R.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Xe={getOperation:function(){return R.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return R.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var b=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:b,fromContext:v,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&console.log(e),[2]}))}))}))),r.on(ft.type,ct((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Ct())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(Tt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof H?[2,t.transition(kt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(dt.type,ct((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r.metadata))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof H?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(gt.type,(function(e,t){return Mt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(bt.type,(function(e){return Gt.with(n({},e))}));var Ut=new Ye("HANDSHAKE_FAILURE");Ut.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),Ut.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Rt=new Ye("STOPPED");Rt.on(gt.type,(function(e,t){return Rt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(bt.type,(function(e){return It.with(n({},e))}));var jt=new Ye("RECEIVE_FAILURE");jt.on(Et.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),jt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ft(e)})),xt.onExit((function(){return ft.cancel})),xt.on(Tt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),xt.on(kt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Ct.type,(function(e){return jt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason})})),xt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return pt.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[ht(t.payload.events)])})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Ft.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(Tt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),Dt.on(kt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Ct.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return lt(e.channels,e.groups)})),Gt.onExit((function(){return lt.cancel})),Gt.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Ft.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(vt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Ft=new Ye("UNSUBSCRIBED");Ft.on(gt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Kt=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Ft,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(gt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(bt())},e.prototype.disconnect=function(){this.engine.transition(yt())},e}(),Lt=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new _({setup:e});this._config=o;var s=new w({config:o}),c=e.cryptography;r.init(o);var l=new L(o,i);this._tokenManager=l;var p=new j({maximumSamplesCount:6e4});this._telemetryManager=p;var h={config:o,networking:r,crypto:s,cryptography:c,tokenManager:l,telemetryManager:p,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return c.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return c.decryptFile(e,n,t.File)};var f=W.bind(this,h,Je),d=W.bind(this,h,ie),g=W.bind(this,h,se),y=W.bind(this,h,ue),b=W.bind(this,h,We),v=new K;if(this._listenerManager=v,this.iAmHere=W.bind(this,h,se),this.iAmAway=W.bind(this,h,ie),this.setPresenceState=W.bind(this,h,ue),this.handshake=W.bind(this,h,Xe),this.receiveMessages=W.bind(this,h,$e),!0===o.enableSubscribeBeta){var m=new Kt({handshake:this.handshake,receiveEvents:this.receiveMessages});this.subscribe=m.subscribe.bind(m),this.unsubscribe=m.unsubscribe.bind(m),this.eventEngine=m}else{var O=new U({timeEndpoint:f,leaveEndpoint:d,heartbeatEndpoint:g,setStateEndpoint:y,subscribeEndpoint:b,crypto:h.crypto,config:h.config,listenerManager:v,getFileUrl:function(e){return be(h,e)}});this.subscribe=O.adaptSubscribeChange.bind(O),this.unsubscribe=O.adaptUnsubscribeChange.bind(O),this.disconnect=O.disconnect.bind(O),this.reconnect=O.reconnect.bind(O),this.unsubscribeAll=O.unsubscribeAll.bind(O),this.getSubscribedChannels=O.getSubscribedChannels.bind(O),this.getSubscribedChannelGroups=O.getSubscribedChannelGroups.bind(O),this.setState=O.adaptStateChange.bind(O),this.presence=O.adaptPresenceChange.bind(O),this.destroy=function(e){O.unsubscribeAll(e),O.disconnect()}}this.addListener=v.addListener.bind(v),this.removeListener=v.removeListener.bind(v),this.removeAllListeners=v.removeAllListeners.bind(v),this.parseToken=l.parseToken.bind(l),this.setToken=l.setToken.bind(l),this.getToken=l.getToken.bind(l),this.channelGroups={listGroups:W.bind(this,h,Y),listChannels:W.bind(this,h,Z),addChannels:W.bind(this,h,X),removeChannels:W.bind(this,h,$),deleteGroup:W.bind(this,h,Q)},this.push={addChannels:W.bind(this,h,ee),removeChannels:W.bind(this,h,te),deleteDevice:W.bind(this,h,re),listChannels:W.bind(this,h,ne)},this.hereNow=W.bind(this,h,ce),this.whereNow=W.bind(this,h,oe),this.getState=W.bind(this,h,ae),this.grant=W.bind(this,h,Re),this.grantToken=W.bind(this,h,De),this.audit=W.bind(this,h,Ue),this.revokeToken=W.bind(this,h,Ge),this.publish=W.bind(this,h,Ke),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=W.bind(this,h,Le),this.history=W.bind(this,h,Be),this.deleteMessages=W.bind(this,h,qe),this.messageCounts=W.bind(this,h,ze),this.fetchMessages=W.bind(this,h,Ve),this.addMessageAction=W.bind(this,h,le),this.removeMessageAction=W.bind(this,h,pe),this.getMessageActions=W.bind(this,h,he),this.listFiles=W.bind(this,h,fe);var P=W.bind(this,h,de);this.publishFile=W.bind(this,h,ge),this.sendFile=ye({generateUploadUrl:P,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return be(h,e)},this.downloadFile=W.bind(this,h,ve),this.deleteFile=W.bind(this,h,me),this.objects={getAllUUIDMetadata:W.bind(this,h,_e),getUUIDMetadata:W.bind(this,h,Oe),setUUIDMetadata:W.bind(this,h,Pe),removeUUIDMetadata:W.bind(this,h,Se),getAllChannelMetadata:W.bind(this,h,we),getChannelMetadata:W.bind(this,h,Ne),setChannelMetadata:W.bind(this,h,Te),removeChannelMetadata:W.bind(this,h,ke),getChannelMembers:W.bind(this,h,Ce),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function Bt(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}function qt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?qt(s):s})),n}var zt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),Vt={exports:{}},Jt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void tn(Xt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Xt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function on(e,t,n,r){void 0===r&&(r=Zt());var i,o=sn(e,"",0,[],void 0,0,r)||e;try{i=0===Yt.length?JSON.stringify(o,t,n):JSON.stringify(o,an(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Qt.length;){var s=Qt.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function sn(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void tn(Xt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Xt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(dn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===hn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=gn[u]:u<2048?s+=gn[192|u>>6]+gn[128|63&u]:u<55296||u>=57344?s+=gn[224|u>>12]+gn[128|u>>6&63]+gn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=gn[240|u>>18]+gn[128|u>>12&63]+gn[128|u>>6&63]+gn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(dn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(Pn(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},In=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&Mn.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},Dn={formats:pn,parse:function(e,t){var n=function(e){if(!e)return Rn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?Rn.charset:e.charset;return{allowDots:void 0===e.allowDots?Rn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:Rn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:Rn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Rn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:Rn.comma,decoder:"function"==typeof e.decoder?e.decoder:Rn.decoder,delimiter:"string"==typeof e.delimiter||An.isRegExp(e.delimiter)?e.delimiter:Rn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:Rn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:Rn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:Rn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:Rn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Rn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Un(l)?[l]:l),Mn.call(r,c)?r[c]=An.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Gn(e){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gn(e)}var Fn=function(e){return null!==e&&"object"===Gn(e)};function Kn(e){return Kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kn(e)}var Ln=Fn,Hn=Bn;function Bn(e){if(e)return function(e){for(var t in Bn.prototype)Object.prototype.hasOwnProperty.call(Bn.prototype,t)&&(e[t]=Bn.prototype[t]);return e}(e)}Bn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Bn.prototype.parse=function(e){return this._parser=e,this},Bn.prototype.responseType=function(e){return this._responseType=e,this},Bn.prototype.serialize=function(e){return this._serializer=e,this},Bn.prototype.timeout=function(e){if(!e||"object"!==Kn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Bn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var qn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),zn=new Set([408,413,429,500,502,503,504,521,522,524]);Bn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&zn.has(t.status))return!0;if(e){if(e.code&&qn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Bn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Bn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Bn.prototype.catch=function(e){return this.then(void 0,e)},Bn.prototype.use=function(e){return e(this),this},Bn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Bn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Bn.prototype.get=function(e){return this._header[e.toLowerCase()]},Bn.prototype.getHeader=Bn.prototype.get,Bn.prototype.set=function(e,t){if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Bn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Bn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Bn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Bn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Bn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Bn.prototype.redirects=function(e){return this._maxRedirects=e,this},Bn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Bn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Bn.prototype.send=function(e){var t=Ln(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Ln(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Bn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Bn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Bn.prototype._appendQueryString=function(){console.warn("Unsupported")},Bn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Bn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var Vn={};function Jn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Wn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Wn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Wn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},v.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=v,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(Vt,Vt.exports);var nr=Vt.exports;function rr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function ir(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(rr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function or(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=nr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function sr(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ar(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ur(e,t,n,r){var i=nr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function cr(e,t,n,r){var i=nr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function lr(e,t,n){var r=nr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function pr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var hr,fr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=pr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=pr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),dr=(hr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),hr.supportsFile="undefined"!=typeof File,hr.supportsBlob="undefined"!=typeof Blob,hr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,hr.supportsBuffer=!1,hr.supportsStream=!1,hr.supportsString=!0,hr.supportsEncryptFile=!0,hr.supportsFileUri=!1,hr);function gr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var yr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:lr,get:ar,post:ur,patch:cr,sendBeacon:gr,getfile:sr,postfile:or}),t.cbor=new zt((function(e){return qt(p.decode(e))}),Bt),t.PubNubFile=dr,t.cryptography=new fr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Lt);return yr})); diff --git a/lib/core/components/_endpoint.js b/lib/core/components/_endpoint.js new file mode 100644 index 000000000..c8ad2e549 --- /dev/null +++ b/lib/core/components/_endpoint.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/core/constants/operations.js b/lib/core/constants/operations.js index 5a934e464..8dad48b82 100644 --- a/lib/core/constants/operations.js +++ b/lib/core/constants/operations.js @@ -1,6 +1,68 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -/* */ +exports.Operation = void 0; +var Operation; +(function (Operation) { + Operation["Time"] = "PNTimeOperation"; + Operation["History"] = "PNHistoryOperation"; + Operation["DeleteMessages"] = "PNDeleteMessagesOperation"; + Operation["FetchMessages"] = "PNFetchMessagesOperation"; + Operation["MessageCounts"] = "PNMessageCountsOperation"; + Operation["Subscribe"] = "PNSubscribeOperation"; + Operation["Unsubscribe"] = "PNUnsubscribeOperation"; + Operation["Publish"] = "PNPublishOperation"; + Operation["Signal"] = "PNSignalOperation"; + Operation["AddMessageAction"] = "PNAddActionOperation"; + Operation["RemoveMessageAction"] = "PNRemoveMessageActionOperation"; + Operation["GetMessageActions"] = "PNGetMessageActionsOperation"; + Operation["CreateUser"] = "PNCreateUserOperation"; + Operation["UpdateUser"] = "PNUpdateUserOperation"; + Operation["RemoveUser"] = "PNRemoveUserOperation"; + Operation["FetchUser"] = "PNFetchUserOperation"; + Operation["GetUsers"] = "PNGetUsersOperation"; + Operation["CreateSpace"] = "PNCreateSpaceOperation"; + Operation["UpdateSpace"] = "PNUpdateSpaceOperation"; + Operation["RemoveSpace"] = "PNRemoveSpaceOperation"; + Operation["FetchSpace"] = "PNFetchSpaceOperation"; + Operation["GetSpaces"] = "PNGetSpacesOperation"; + Operation["GetMembers"] = "PNGetMembersOperation"; + Operation["UpdateMembers"] = "PNUpdateMembersOperation"; + Operation["GetMemberships"] = "PNGetMembershipsOperation"; + Operation["UpdateMemberships"] = "PNUpdateMembershipsOperation"; + Operation["ListFiles"] = "PNListFilesOperation"; + Operation["GenerateUploadUrl"] = "PNGenerateUploadUrlOperation"; + Operation["PublishFile"] = "PNPublishFileOperation"; + Operation["GetFileUrl"] = "PNGetFileUrlOperation"; + Operation["DownloadFile"] = "PNDownloadFileOperation"; + Operation["GetAllUUIDMetadata"] = "PNGetAllUUIDMetadataOperation"; + Operation["GetUUIDMetadata"] = "PNGetUUIDMetadataOperation"; + Operation["SetUUIDMetadata"] = "PNSetUUIDMetadataOperation"; + Operation["RemoveUUIDMetadata"] = "PNRemoveUUIDMetadataOperation"; + Operation["GetAllChannelMetadata"] = "PNGetAllChannelMetadataOperation"; + Operation["GetChannelMetadata"] = "PNGetChannelMetadataOperation"; + Operation["SetChannelMetadata"] = "PNSetChannelMetadataOperation"; + Operation["RemoveChannelMetadata"] = "PNRemoveChannelMetadataOperation"; + Operation["SetMembers"] = "PNSetMembersOperation"; + Operation["SetMemberships"] = "PNSetMembershipsOperation"; + Operation["PushNotificationEnabledChannels"] = "PNPushNotificationEnabledChannelsOperation"; + Operation["RemoveAllPushNotifications"] = "PNRemoveAllPushNotificationsOperation"; + Operation["WhereNow"] = "PNWhereNowOperation"; + Operation["SetState"] = "PNSetStateOperation"; + Operation["HereNow"] = "PNHereNowOperation"; + Operation["GetState"] = "PNGetStateOperation"; + Operation["Heartbeat"] = "PNHeartbeatOperation"; + Operation["ChannelGroups"] = "PNChannelGroupsOperation"; + Operation["RemoveGroup"] = "PNRemoveGroupOperation"; + Operation["ChannelsForGroup"] = "PNChannelsForGroupOperation"; + Operation["AddChannelsToGroup"] = "PNAddChannelsToGroupOperation"; + Operation["RemoveChannelsFromGroup"] = "PNRemoveChannelsFromGroupOperation"; + Operation["AccessManagerGrant"] = "PNAccessManagerGrant"; + Operation["AccessManagerGrantToken"] = "PNAccessManagerGrantToken"; + Operation["AccessManagerAudit"] = "PNAccessManagerAudit"; + Operation["AccessManagerRevokeToken"] = "PNAccessManagerRevokeToken"; + Operation["Handshake"] = "PNHandshakeOperation"; + Operation["ReceiveMessages"] = "PNReceiveMessagesOperation"; +})(Operation = exports.Operation || (exports.Operation = {})); exports.default = { PNTimeOperation: 'PNTimeOperation', PNHistoryOperation: 'PNHistoryOperation', @@ -19,13 +81,13 @@ exports.default = { // Objects API PNCreateUserOperation: 'PNCreateUserOperation', PNUpdateUserOperation: 'PNUpdateUserOperation', - PNDeleteUserOperation: 'PNDeleteUserOperation', - PNGetUserOperation: 'PNGetUsersOperation', + PNRemoveUserOperation: 'PNRemoveUserOperation', + PNFetchUserOperation: 'PNFetchUserOperation', PNGetUsersOperation: 'PNGetUsersOperation', PNCreateSpaceOperation: 'PNCreateSpaceOperation', PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', - PNDeleteSpaceOperation: 'PNDeleteSpaceOperation', - PNGetSpaceOperation: 'PNGetSpacesOperation', + PNRemoveSpaceOperation: 'PNRemoveSpaceOperation', + PNFetchSpaceOperation: 'PNFetchSpaceOperation', PNGetSpacesOperation: 'PNGetSpacesOperation', PNGetMembersOperation: 'PNGetMembersOperation', PNUpdateMembersOperation: 'PNUpdateMembersOperation', diff --git a/lib/core/endpoints/memberships/add_members.js b/lib/core/endpoints/memberships/add_members.js deleted file mode 100644 index 5c203ac62..000000000 --- a/lib/core/endpoints/memberships/add_members.js +++ /dev/null @@ -1,100 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.usePatch = exports.patchURL = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - var users = incomingParams.users; - var payload = {}; - if (users && users.length > 0) { - payload.add = []; - users.forEach(function (addMember) { - var currentAdd = { id: addMember.id }; - if (addMember.custom) { - currentAdd.custom = addMember.custom; - } - payload.add.push(currentAdd); - }); - } - return payload; -} -function getOperation() { - return operations_1.default.PNUpdateMembersOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var spaceId = incomingParams.spaceId, users = incomingParams.users; - if (!spaceId) - return 'Missing spaceId'; - if (!users) - return 'Missing users'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId), "/users"); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId), "/users"); -} -exports.patchURL = patchURL; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.spaceFields) { - includes.push('space'); - } - if (include.customSpaceFields) { - includes.push('space.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, membersResponse) { - return membersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/memberships/get_members.js b/lib/core/endpoints/memberships/get_members.js deleted file mode 100644 index 979e7aa4a..000000000 --- a/lib/core/endpoints/memberships/get_members.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function getOperation() { - return operations_1.default.PNGetMembersOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var spaceId = incomingParams.spaceId; - if (!spaceId) - return 'Missing spaceId'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId), "/users"); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page, filter = incomingParams.filter; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.userFields) { - includes.push('user'); - } - if (include.customUserFields) { - includes.push('user.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - if (filter) { - params.filter = filter; - } - return params; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, membersResponse) { - return membersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/memberships/get_memberships.js b/lib/core/endpoints/memberships/get_memberships.js deleted file mode 100644 index 043551b25..000000000 --- a/lib/core/endpoints/memberships/get_memberships.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function getOperation() { - return operations_1.default.PNGetMembershipsOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var userId = incomingParams.userId; - if (!userId) - return 'Missing userId'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId), "/spaces"); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page, filter = incomingParams.filter; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.spaceFields) { - includes.push('space'); - } - if (include.customSpaceFields) { - includes.push('space.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - if (filter) { - params.filter = filter; - } - return params; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, membershipsResponse) { - return membershipsResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/memberships/join_spaces.js b/lib/core/endpoints/memberships/join_spaces.js deleted file mode 100644 index d31b74f97..000000000 --- a/lib/core/endpoints/memberships/join_spaces.js +++ /dev/null @@ -1,100 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.usePatch = exports.patchURL = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - var spaces = incomingParams.spaces; - var payload = {}; - if (spaces && spaces.length > 0) { - payload.add = []; - spaces.forEach(function (addMembership) { - var currentAdd = { id: addMembership.id }; - if (addMembership.custom) { - currentAdd.custom = addMembership.custom; - } - payload.add.push(currentAdd); - }); - } - return payload; -} -function getOperation() { - return operations_1.default.PNUpdateMembershipsOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var userId = incomingParams.userId, spaces = incomingParams.spaces; - if (!userId) - return 'Missing userId'; - if (!spaces) - return 'Missing spaces'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId), "/spaces"); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId), "/spaces"); -} -exports.patchURL = patchURL; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.spaceFields) { - includes.push('space'); - } - if (include.customSpaceFields) { - includes.push('space.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, membershipsResponse) { - return membershipsResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/memberships/leave_spaces.js b/lib/core/endpoints/memberships/leave_spaces.js deleted file mode 100644 index 7cfddc161..000000000 --- a/lib/core/endpoints/memberships/leave_spaces.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.usePatch = exports.patchURL = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - var spaces = incomingParams.spaces; - var payload = {}; - if (spaces && spaces.length > 0) { - payload.remove = []; - spaces.forEach(function (removeMembershipId) { - payload.remove.push({ id: removeMembershipId }); - }); - } - return payload; -} -function getOperation() { - return operations_1.default.PNUpdateMembershipsOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var userId = incomingParams.userId, spaces = incomingParams.spaces; - if (!userId) - return 'Missing userId'; - if (!spaces) - return 'Missing spaces'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId), "/spaces"); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId), "/spaces"); -} -exports.patchURL = patchURL; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.spaceFields) { - includes.push('space'); - } - if (include.customSpaceFields) { - includes.push('space.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, membershipsResponse) { - return membershipsResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/memberships/remove_members.js b/lib/core/endpoints/memberships/remove_members.js deleted file mode 100644 index bc0b10398..000000000 --- a/lib/core/endpoints/memberships/remove_members.js +++ /dev/null @@ -1,96 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.usePatch = exports.patchURL = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - var users = incomingParams.users; - var payload = {}; - if (users && users.length > 0) { - payload.remove = []; - users.forEach(function (removeMemberId) { - payload.remove.push({ id: removeMemberId }); - }); - } - return payload; -} -function getOperation() { - return operations_1.default.PNUpdateMembersOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var spaceId = incomingParams.spaceId, users = incomingParams.users; - if (!spaceId) - return 'Missing spaceId'; - if (!users) - return 'Missing users'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId), "/users"); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId), "/users"); -} -exports.patchURL = patchURL; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.spaceFields) { - includes.push('space'); - } - if (include.customSpaceFields) { - includes.push('space.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, membersResponse) { - return membersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/memberships/update_members.js b/lib/core/endpoints/memberships/update_members.js deleted file mode 100644 index 859afa63a..000000000 --- a/lib/core/endpoints/memberships/update_members.js +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.usePatch = exports.patchURL = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - var addMembers = incomingParams.addMembers, updateMembers = incomingParams.updateMembers, removeMembers = incomingParams.removeMembers, users = incomingParams.users; - var payload = {}; - if (addMembers && addMembers.length > 0) { - payload.add = []; - addMembers.forEach(function (addMember) { - var currentAdd = { id: addMember.id }; - if (addMember.custom) { - currentAdd.custom = addMember.custom; - } - payload.add.push(currentAdd); - }); - } - if (updateMembers && updateMembers.length > 0) { - payload.update = []; - updateMembers.forEach(function (updateMember) { - var currentUpdate = { id: updateMember.id }; - if (updateMember.custom) { - currentUpdate.custom = updateMember.custom; - } - payload.update.push(currentUpdate); - }); - } - // if users is present then it is an update - if (users && users.length > 0) { - payload.update = payload.update || []; - users.forEach(function (updateMember) { - var currentUpdate = { id: updateMember.id }; - if (updateMember.custom) { - currentUpdate.custom = updateMember.custom; - } - payload.update.push(currentUpdate); - }); - } - if (removeMembers && removeMembers.length > 0) { - payload.remove = []; - removeMembers.forEach(function (removeMemberId) { - payload.remove.push({ id: removeMemberId }); - }); - } - return payload; -} -function getOperation() { - return operations_1.default.PNUpdateMembersOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var spaceId = incomingParams.spaceId, users = incomingParams.users; - if (!spaceId) - return 'Missing spaceId'; - if (!users) - return 'Missing users'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId), "/users"); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId), "/users"); -} -exports.patchURL = patchURL; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.spaceFields) { - includes.push('space'); - } - if (include.customSpaceFields) { - includes.push('space.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, membersResponse) { - return membersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/memberships/update_memberships.js b/lib/core/endpoints/memberships/update_memberships.js deleted file mode 100644 index d8adef624..000000000 --- a/lib/core/endpoints/memberships/update_memberships.js +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.usePatch = exports.patchURL = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - var addMemberships = incomingParams.addMemberships, updateMemberships = incomingParams.updateMemberships, removeMemberships = incomingParams.removeMemberships, spaces = incomingParams.spaces; - var payload = {}; - if (addMemberships && addMemberships.length > 0) { - payload.add = []; - addMemberships.forEach(function (addMembership) { - var currentAdd = { id: addMembership.id }; - if (addMembership.custom) { - currentAdd.custom = addMembership.custom; - } - payload.add.push(currentAdd); - }); - } - if (updateMemberships && updateMemberships.length > 0) { - payload.update = []; - updateMemberships.forEach(function (updateMembership) { - var currentUpdate = { id: updateMembership.id }; - if (updateMembership.custom) { - currentUpdate.custom = updateMembership.custom; - } - payload.update.push(currentUpdate); - }); - } - // if spaces is present then it is an update - if (spaces && spaces.length > 0) { - payload.update = payload.update || []; - spaces.forEach(function (updateMembership) { - var currentUpdate = { id: updateMembership.id }; - if (updateMembership.custom) { - currentUpdate.custom = updateMembership.custom; - } - payload.update.push(currentUpdate); - }); - } - if (removeMemberships && removeMemberships.length > 0) { - payload.remove = []; - removeMemberships.forEach(function (removeMembershipId) { - payload.remove.push({ id: removeMembershipId }); - }); - } - return payload; -} -function getOperation() { - return operations_1.default.PNUpdateMembershipsOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var userId = incomingParams.userId, spaces = incomingParams.spaces; - if (!userId) - return 'Missing userId'; - if (!spaces) - return 'Missing spaces'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId), "/spaces"); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId), "/spaces"); -} -exports.patchURL = patchURL; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - if (include.spaceFields) { - includes.push('space'); - } - if (include.customSpaceFields) { - includes.push('space.custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, membershipsResponse) { - return membershipsResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/objects/channel/channel.js b/lib/core/endpoints/objects/channel/channel.js deleted file mode 100644 index 1e44d895d..000000000 --- a/lib/core/endpoints/objects/channel/channel.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -/** */ diff --git a/lib/core/endpoints/objects/member/member.js b/lib/core/endpoints/objects/member/member.js deleted file mode 100644 index 1e44d895d..000000000 --- a/lib/core/endpoints/objects/member/member.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -/** */ diff --git a/lib/core/endpoints/objects/membership/membership.js b/lib/core/endpoints/objects/membership/membership.js deleted file mode 100644 index 1e44d895d..000000000 --- a/lib/core/endpoints/objects/membership/membership.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -/** */ diff --git a/lib/core/endpoints/objects/uuid/uuid.js b/lib/core/endpoints/objects/uuid/uuid.js deleted file mode 100644 index 1e44d895d..000000000 --- a/lib/core/endpoints/objects/uuid/uuid.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -/** */ diff --git a/lib/core/endpoints/spaces/create_space.js b/lib/core/endpoints/spaces/create_space.js deleted file mode 100644 index da37e26d3..000000000 --- a/lib/core/endpoints/spaces/create_space.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.postPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.postURL = exports.getURL = exports.usePost = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -function prepareMessagePayload(modules, incomingParams) { - return incomingParams; -} -function getOperation() { - return operations_1.default.PNCreateSpaceOperation; -} -exports.getOperation = getOperation; -function validateParams(_a, incomingParams) { - var config = _a.config; - var id = incomingParams.id, name = incomingParams.name, custom = incomingParams.custom; - if (!id) - return 'Missing Space.id'; - if (!name) - return 'Missing Space.name'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (custom) { - if (!Object.values(custom).every(function (value) { return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'; })) { - return 'Invalid custom type, only string, number and boolean values are allowed.'; - } - } -} -exports.validateParams = validateParams; -function usePost() { - return true; -} -exports.usePost = usePost; -function getURL(modules) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces"); -} -exports.getURL = getURL; -function postURL(modules) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces"); -} -exports.postURL = postURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include; - var params = {}; - // default to include custom fields in response - if (!include) { - include = { - customFields: true, - }; - } - else if (include.customFields === undefined) { - include.customFields = true; - } - if (include) { - var includes = []; - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - return params; -} -exports.prepareParams = prepareParams; -function postPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.postPayload = postPayload; -function handleResponse(modules, spacesResponse) { - return spacesResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/spaces/delete_space.js b/lib/core/endpoints/spaces/delete_space.js deleted file mode 100644 index 4fccf0395..000000000 --- a/lib/core/endpoints/spaces/delete_space.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.useDelete = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function getOperation() { - return operations_1.default.PNDeleteSpaceOperation; -} -exports.getOperation = getOperation; -function validateParams(_a, spaceId) { - var config = _a.config; - if (!spaceId) - return 'Missing SpaceId'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; -} -exports.validateParams = validateParams; -function useDelete() { - return true; -} -exports.useDelete = useDelete; -function getURL(modules, spaceId) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(spaceId)); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams() { - return {}; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, spacesResponse) { - return spacesResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/spaces/get_space.js b/lib/core/endpoints/spaces/get_space.js deleted file mode 100644 index 5ebbf27fe..000000000 --- a/lib/core/endpoints/spaces/get_space.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function getOperation() { - return operations_1.default.PNGetSpaceOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var spaceId = incomingParams.spaceId; - if (!spaceId) - return 'Missing spaceId'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(incomingParams.spaceId)); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include; - var params = {}; - // default to include custom fields in response - if (!include) { - include = { - customFields: true, - }; - } - else if (include.customFields === undefined) { - include.customFields = true; - } - if (include) { - var includes = []; - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - return params; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, spacesResponse) { - return spacesResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/spaces/get_spaces.js b/lib/core/endpoints/spaces/get_spaces.js deleted file mode 100644 index ef3f1d73b..000000000 --- a/lib/core/endpoints/spaces/get_spaces.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -function getOperation() { - return operations_1.default.PNGetSpacesOperation; -} -exports.getOperation = getOperation; -function validateParams() { - // no required parameters -} -exports.validateParams = validateParams; -function getURL(modules) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/spaces"); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page, filter = incomingParams.filter; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - if (filter) { - params.filter = filter; - } - return params; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, spacesResponse) { - return spacesResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/spaces/update_space.js b/lib/core/endpoints/spaces/update_space.js deleted file mode 100644 index af15054c6..000000000 --- a/lib/core/endpoints/spaces/update_space.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.patchURL = exports.getURL = exports.usePatch = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - return incomingParams; -} -function getOperation() { - return operations_1.default.PNUpdateSpaceOperation; -} -exports.getOperation = getOperation; -function validateParams(_a, incomingParams) { - var config = _a.config; - var id = incomingParams.id, name = incomingParams.name, custom = incomingParams.custom; - if (!id) - return 'Missing Space.id'; - if (!name) - return 'Missing Space.name'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (custom) { - if (!Object.values(custom).every(function (value) { return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'; })) { - return 'Invalid custom type, only string, number and boolean values are allowed.'; - } - } -} -exports.validateParams = validateParams; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getURL(modules, incomingParams) { - var config = modules.config; - var id = incomingParams.id; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(id)); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - var id = incomingParams.id; - return "/v1/objects/".concat(config.subscribeKey, "/spaces/").concat(utils_1.default.encodeString(id)); -} -exports.patchURL = patchURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include; - var params = {}; - // default to include custom fields in response - if (!include) { - include = { - customFields: true, - }; - } - else if (include.customFields === undefined) { - include.customFields = true; - } - if (include) { - var includes = []; - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, spacesResponse) { - return spacesResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/user/create.js b/lib/core/endpoints/user/create.js new file mode 100644 index 000000000..e9526855c --- /dev/null +++ b/lib/core/endpoints/user/create.js @@ -0,0 +1,40 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var operations_1 = __importDefault(require("../../constants/operations")); +var utils_1 = __importDefault(require("../../utils")); +var endpoint = { + getOperation: function () { return operations_1.default.PNCreateUserOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.data)) { + return 'Data cannot be empty'; + } + }, + usePost: function () { return true; }, + postURL: function (_a, params) { + var _b; + var config = _a.config; + return "/v3/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString((_b = params.userId) !== null && _b !== void 0 ? _b : config.getUserId())); + }, + postPayload: function (_, params) { return params.data; }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_a, params) { + var _b; + var config = _a.config; + var queryParams = { + uuid: (_b = params === null || params === void 0 ? void 0 : params.userId) !== null && _b !== void 0 ? _b : config.getUserId(), + }; + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, +}; +exports.default = endpoint; diff --git a/lib/core/endpoints/user/fetch.js b/lib/core/endpoints/user/fetch.js new file mode 100644 index 000000000..473da58c5 --- /dev/null +++ b/lib/core/endpoints/user/fetch.js @@ -0,0 +1,34 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var operations_1 = __importDefault(require("../../constants/operations")); +var utils_1 = __importDefault(require("../../utils")); +var endpoint = { + getOperation: function () { return operations_1.default.PNFetchUserOperation; }, + validateParams: function () { + // No required parameters. + }, + getURL: function (_a, params) { + var _b; + var config = _a.config; + return "/v3/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString((_b = params === null || params === void 0 ? void 0 : params.userId) !== null && _b !== void 0 ? _b : config.getUserId())); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_a, params) { + var _b; + var config = _a.config; + var queryParams = { uuid: (_b = params === null || params === void 0 ? void 0 : params.userId) !== null && _b !== void 0 ? _b : config.getUserId() }; + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, +}; +exports.default = endpoint; diff --git a/lib/core/endpoints/users/create_user.js b/lib/core/endpoints/users/create_user.js deleted file mode 100644 index a9ca667b8..000000000 --- a/lib/core/endpoints/users/create_user.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.postPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.postURL = exports.getURL = exports.usePost = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -function prepareMessagePayload(modules, incomingParams) { - return incomingParams; -} -function getOperation() { - return operations_1.default.PNCreateUserOperation; -} -exports.getOperation = getOperation; -function validateParams(_a, incomingParams) { - var config = _a.config; - var id = incomingParams.id, name = incomingParams.name, custom = incomingParams.custom; - if (!id) - return 'Missing User.id'; - if (!name) - return 'Missing User.name'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (custom) { - if (!Object.values(custom).every(function (value) { return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'; })) { - return 'Invalid custom type, only string, number and boolean values are allowed.'; - } - } -} -exports.validateParams = validateParams; -function usePost() { - return true; -} -exports.usePost = usePost; -function getURL(modules) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users"); -} -exports.getURL = getURL; -function postURL(modules) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users"); -} -exports.postURL = postURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include; - var params = {}; - // default to include custom fields in response - if (!include) { - include = { - customFields: true, - }; - } - else if (include.customFields === undefined) { - include.customFields = true; - } - if (include) { - var includes = []; - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - return params; -} -exports.prepareParams = prepareParams; -function postPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.postPayload = postPayload; -function handleResponse(modules, usersResponse) { - return usersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/users/delete_user.js b/lib/core/endpoints/users/delete_user.js deleted file mode 100644 index f243920f8..000000000 --- a/lib/core/endpoints/users/delete_user.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.useDelete = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function getOperation() { - return operations_1.default.PNDeleteUserOperation; -} -exports.getOperation = getOperation; -function validateParams(_a, userId) { - var config = _a.config; - if (!userId) - return 'Missing UserId'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; -} -exports.validateParams = validateParams; -function useDelete() { - return true; -} -exports.useDelete = useDelete; -function getURL(modules, userId) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(userId)); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams() { - return {}; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, usersResponse) { - return usersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/users/get_user.js b/lib/core/endpoints/users/get_user.js deleted file mode 100644 index dc8720472..000000000 --- a/lib/core/endpoints/users/get_user.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function getOperation() { - return operations_1.default.PNGetUserOperation; -} -exports.getOperation = getOperation; -function validateParams(modules, incomingParams) { - var userId = incomingParams.userId; - if (!userId) - return 'Missing userId'; -} -exports.validateParams = validateParams; -function getURL(modules, incomingParams) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(incomingParams.userId)); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include; - var params = {}; - // default to include custom fields in response - if (!include) { - include = { - customFields: true, - }; - } - else if (include.customFields === undefined) { - include.customFields = true; - } - if (include) { - var includes = []; - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - return params; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, usersResponse) { - return usersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/users/get_users.js b/lib/core/endpoints/users/get_users.js deleted file mode 100644 index b21cf0de3..000000000 --- a/lib/core/endpoints/users/get_users.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -function getOperation() { - return operations_1.default.PNGetUsersOperation; -} -exports.getOperation = getOperation; -function validateParams() { - // no required parameters -} -exports.validateParams = validateParams; -function getURL(modules) { - var config = modules.config; - return "/v1/objects/".concat(config.subscribeKey, "/users"); -} -exports.getURL = getURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include, limit = incomingParams.limit, page = incomingParams.page, filter = incomingParams.filter; - var params = {}; - if (limit) { - params.limit = limit; - } - if (include) { - var includes = []; - if (include.totalCount) { - params.count = true; - } - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - if (page) { - if (page.next) { - params.start = page.next; - } - if (page.prev) { - params.end = page.prev; - } - } - if (filter) { - params.filter = filter; - } - return params; -} -exports.prepareParams = prepareParams; -function handleResponse(modules, usersResponse) { - return usersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/endpoints/users/update_user.js b/lib/core/endpoints/users/update_user.js deleted file mode 100644 index 1e34a7bd3..000000000 --- a/lib/core/endpoints/users/update_user.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -/* */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handleResponse = exports.patchPayload = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.patchURL = exports.getURL = exports.usePatch = exports.validateParams = exports.getOperation = void 0; -var operations_1 = require("../../constants/operations"); -var utils_1 = require("../../utils"); -function prepareMessagePayload(modules, incomingParams) { - return incomingParams; -} -function getOperation() { - return operations_1.default.PNUpdateUserOperation; -} -exports.getOperation = getOperation; -function validateParams(_a, incomingParams) { - var config = _a.config; - var id = incomingParams.id, name = incomingParams.name, custom = incomingParams.custom; - if (!id) - return 'Missing User.id'; - if (!name) - return 'Missing User.name'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (custom) { - if (!Object.values(custom).every(function (value) { return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean'; })) { - return 'Invalid custom type, only string, number and boolean values are allowed.'; - } - } -} -exports.validateParams = validateParams; -function usePatch() { - return true; -} -exports.usePatch = usePatch; -function getURL(modules, incomingParams) { - var config = modules.config; - var id = incomingParams.id; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(id)); -} -exports.getURL = getURL; -function patchURL(modules, incomingParams) { - var config = modules.config; - var id = incomingParams.id; - return "/v1/objects/".concat(config.subscribeKey, "/users/").concat(utils_1.default.encodeString(id)); -} -exports.patchURL = patchURL; -function getRequestTimeout(_a) { - var config = _a.config; - return config.getTransactionTimeout(); -} -exports.getRequestTimeout = getRequestTimeout; -function isAuthSupported() { - return true; -} -exports.isAuthSupported = isAuthSupported; -function prepareParams(modules, incomingParams) { - var include = incomingParams.include; - var params = {}; - // default to include custom fields in response - if (!include) { - include = { - customFields: true, - }; - } - else if (include.customFields === undefined) { - include.customFields = true; - } - if (include) { - var includes = []; - if (include.customFields) { - includes.push('custom'); - } - var includesString = includes.join(','); - if (includesString.length > 0) { - params.include = includesString; - } - } - return params; -} -exports.prepareParams = prepareParams; -function patchPayload(modules, incomingParams) { - return prepareMessagePayload(modules, incomingParams); -} -exports.patchPayload = patchPayload; -function handleResponse(modules, usersResponse) { - return usersResponse; -} -exports.handleResponse = handleResponse; diff --git a/lib/core/flow_interfaces.js b/lib/core/flow_interfaces.js deleted file mode 100644 index a6efc90d3..000000000 --- a/lib/core/flow_interfaces.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -/* eslint no-unused-vars: 0 */ -// ****************** SUBSCRIPTIONS ******************************************** -// subscribe responses -// ***************************************************************************** -// ****************** Announcements ******************************************** -// ***************************************************************************** -// Time endpoints -// history -// history -// CG endpoints -// -// push -// -// presence -// -// -// -// subscribe -// -// access manager -// Base permissions object -// publish -// signal -// Actions -// Users Object -// Spaces Object -// Memberships Object -// Members Object -// -module.exports = {}; diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index 58e037d33..6611326ce 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -12,7 +12,11 @@ var __assign = (this && this.__assign) || function () { }; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; diff --git a/lib/db/common.js b/lib/db/common.js deleted file mode 100644 index 1f145f464..000000000 --- a/lib/db/common.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var default_1 = /** @class */ (function () { - function default_1() { - this.storage = {}; - } - default_1.prototype.get = function (key) { - return this.storage[key]; - }; - default_1.prototype.set = function (key, value) { - this.storage[key] = value; - }; - return default_1; -}()); -exports.default = default_1; diff --git a/lib/db/web.js b/lib/db/web.js deleted file mode 100644 index 477743cc0..000000000 --- a/lib/db/web.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -/* */ -/* global localStorage */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = { - get: function (key) { - // try catch for operating within iframes which disable localStorage - try { - return localStorage.getItem(key); - } - catch (e) { - return null; - } - }, - set: function (key, data) { - // try catch for operating within iframes which disable localStorage - try { - return localStorage.setItem(key, data); - } - catch (e) { - return null; - } - }, -}; diff --git a/lib/event-engine/dispatcher.js b/lib/event-engine/dispatcher.js index c53232832..1a39d5e78 100644 --- a/lib/event-engine/dispatcher.js +++ b/lib/event-engine/dispatcher.js @@ -16,7 +16,11 @@ var __extends = (this && this.__extends) || (function () { })(); var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; diff --git a/lib/event-engine/index.js b/lib/event-engine/index.js index cf1a241fe..e5c655e05 100644 --- a/lib/event-engine/index.js +++ b/lib/event-engine/index.js @@ -1,7 +1,11 @@ "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; diff --git a/lib/nativescript/index.js b/lib/nativescript/index.js index 527d72596..595f49acb 100644 --- a/lib/nativescript/index.js +++ b/lib/nativescript/index.js @@ -26,7 +26,6 @@ var nativescript_1 = require("../networking/modules/nativescript"); var default_1 = /** @class */ (function (_super) { __extends(default_1, _super); function default_1(setup) { - var _this = this; setup.db = new common_1.default(); setup.networking = new networking_1.default({ del: nativescript_1.del, @@ -35,8 +34,7 @@ var default_1 = /** @class */ (function (_super) { patch: nativescript_1.patch, }); setup.sdkFamily = 'NativeScript'; - _this = _super.call(this, setup) || this; - return _this; + return _super.call(this, setup) || this; } return default_1; }(pubnub_common_1.default)); diff --git a/lib/node/index.js b/lib/node/index.js index 643cff838..c0a83be52 100644 --- a/lib/node/index.js +++ b/lib/node/index.js @@ -29,7 +29,6 @@ var node_3 = __importDefault(require("../file/modules/node")); module.exports = /** @class */ (function (_super) { __extends(class_1, _super); function class_1(setup) { - var _this = this; setup.cbor = new common_1.default(function (buffer) { return cbor_sync_1.default.decode(Buffer.from(buffer)); }, base64_codec_1.decode); setup.networking = new networking_1.default({ keepAlive: node_1.keepAlive, @@ -47,8 +46,7 @@ module.exports = /** @class */ (function (_super) { if (!('ssl' in setup)) { setup.ssl = true; } - _this = _super.call(this, setup) || this; - return _this; + return _super.call(this, setup) || this; } return class_1; }(pubnub_common_1.default)); diff --git a/lib/react_native/index.js b/lib/react_native/index.js index 6ae4867c7..8c1e501cb 100644 --- a/lib/react_native/index.js +++ b/lib/react_native/index.js @@ -32,7 +32,6 @@ global.Buffer = global.Buffer || buffer_1.Buffer; var default_1 = /** @class */ (function (_super) { __extends(default_1, _super); function default_1(setup) { - var _this = this; setup.cbor = new common_1.default(function (arrayBuffer) { return (0, stringify_buffer_keys_1.stringifyBufferKeys)(cbor_js_1.default.decode(arrayBuffer)); }, base64_codec_1.decode); setup.PubNubFile = react_native_2.default; setup.networking = new networking_1.default({ @@ -45,8 +44,7 @@ var default_1 = /** @class */ (function (_super) { }); setup.sdkFamily = 'ReactNative'; setup.ssl = true; - _this = _super.call(this, setup) || this; - return _this; + return _super.call(this, setup) || this; } return default_1; }(pubnub_common_1.default)); diff --git a/lib/titanium/index.js b/lib/titanium/index.js index a369bef9c..f577196b7 100644 --- a/lib/titanium/index.js +++ b/lib/titanium/index.js @@ -27,7 +27,6 @@ var titanium_1 = require("../networking/modules/titanium"); var PubNub = /** @class */ (function (_super) { __extends(PubNub, _super); function PubNub(setup) { - var _this = this; setup.cbor = new common_1.default(cbor_sync_1.default.decode, function (base64String) { return Buffer.from(base64String, 'base64'); }); setup.sdkFamily = 'TitaniumSDK'; setup.networking = new networking_1.default({ @@ -36,8 +35,7 @@ var PubNub = /** @class */ (function (_super) { post: titanium_1.post, patch: titanium_1.patch, }); - _this = _super.call(this, setup) || this; - return _this; + return _super.call(this, setup) || this; } return PubNub; }(pubnub_common_1.default)); diff --git a/package-lock.json b/package-lock.json index d7d977359..789d48f12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,18 +19,24 @@ }, "devDependencies": { "@cucumber/cucumber": "^7.3.1", + "@cucumber/pretty-formatter": "^1.0.0", "@rollup/plugin-commonjs": "^21.0.2", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.1.3", "@rollup/plugin-typescript": "^8.3.1", + "@types/chai": "^4.3.3", + "@types/cucumber": "^7.0.0", "@types/expect": "^24.3.0", "@types/mocha": "^9.1.0", "@types/nock": "^9.3.1", + "@types/pubnub": "^7.2.0", "@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/parser": "^5.12.1", - "chai": "4.3.4", + "chai": "^4.3.4", "chai-as-promised": "^7.1.1", "chai-nock": "^1.2.0", + "cucumber-pretty": "^6.0.1", + "cucumber-tsflow": "^4.0.0-preview.7", "es6-shim": "^0.35.6", "eslint": "^8.9.0", "eslint-plugin-mocha": "^10.0.3", @@ -55,9 +61,10 @@ "rollup-plugin-terser": "^7.0.2", "sinon": "^7.5.0", "sinon-chai": "^3.3.0", + "source-map-support": "^0.5.21", "ts-mocha": "^9.0.2", - "ts-node": "^10.7.0", - "typescript": "^4.3.5", + "ts-node": "^10.9.1", + "typescript": "^4.8.4", "underscore": "^1.9.2" } }, @@ -96,22 +103,27 @@ "node": ">=6.9.0" } }, - "node_modules/@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "node_modules/@babel/runtime-corejs3": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.0.tgz", + "integrity": "sha512-v1JH7PeAAGBEyTQM9TqojVl+b20zXtesFKCJHu50xMxZKD1fX0TKaKHPsZfFkXfs7D1M9M6Eeqg1FkJ3a0x2dA==", "dev": true, + "peer": true, + "dependencies": { + "core-js-pure": "^3.25.1", + "regenerator-runtime": "^0.13.10" + }, "engines": { - "node": ">= 12" + "node": ">=6.9.0" } }, "node_modules/@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "dependencies": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" }, "engines": { "node": ">=12" @@ -208,6 +220,16 @@ "gherkin-javascript": "bin/gherkin" } }, + "node_modules/@cucumber/gherkin-streams/node_modules/source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/@cucumber/html-formatter": { "version": "15.0.2", "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-15.0.2.tgz", @@ -222,6 +244,16 @@ "cucumber-html-formatter": "bin/cucumber-html-formatter.js" } }, + "node_modules/@cucumber/html-formatter/node_modules/source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/@cucumber/message-streams": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", @@ -243,6 +275,34 @@ "uuid": "8.3.2" } }, + "node_modules/@cucumber/pretty-formatter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", + "integrity": "sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==", + "dev": true, + "dependencies": { + "ansi-styles": "^5.0.0", + "cli-table3": "^0.6.0", + "figures": "^3.2.0", + "ts-dedent": "^2.0.0" + }, + "peerDependencies": { + "@cucumber/cucumber": ">=7.0.0", + "@cucumber/messages": "*" + } + }, + "node_modules/@cucumber/pretty-formatter/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/@cucumber/tag-expressions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@cucumber/tag-expressions/-/tag-expressions-3.0.1.tgz", @@ -417,6 +477,31 @@ "node": ">=8" } }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -614,6 +699,22 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, + "node_modules/@types/chai": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", + "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", + "dev": true + }, + "node_modules/@types/cucumber": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/cucumber/-/cucumber-7.0.0.tgz", + "integrity": "sha512-cr5NN8/jmbw3vDKTQfGW0cSzDtkvxixu9bUD6po9U6OEF04XLuukTDldFG34ccDscLkA8bYnZ7VjxP79cIC7tg==", + "deprecated": "This is a stub types definition. @cucumber/cucumber provides its own type definitions, so you do not need this installed.", + "dev": true, + "dependencies": { + "@cucumber/cucumber": "*" + } + }, "node_modules/@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -688,6 +789,12 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, + "node_modules/@types/pubnub": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", + "integrity": "sha512-Ui58Xsn8/4Ty1hFW0t91ED6FKezzipjO+GEJviOdJdqp817+I5/WMfo5zBsDfjbZQWMqcdrktMauKpUqiIF1wA==", + "dev": true + }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -1308,6 +1415,13 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==", + "dev": true, + "peer": true + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -1771,6 +1885,18 @@ "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" }, + "node_modules/core-js-pure": { + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", + "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", + "dev": true, + "hasInstallScript": true, + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -1811,6 +1937,185 @@ "node": ">= 8" } }, + "node_modules/cucumber": { + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.7.tgz", + "integrity": "sha512-pN3AgWxHx8rOi+wOlqjASNETOjf3TgeyqhMNLQam7nSTXgQzju1oAmXkleRQRcXvpVvejcDHiZBLFSfBkqbYpA==", + "deprecated": "Cucumber is publishing new releases under @cucumber/cucumber", + "dev": true, + "peer": true, + "dependencies": { + "assertion-error-formatter": "^3.0.0", + "bluebird": "^3.4.1", + "cli-table3": "^0.5.1", + "colors": "^1.1.2", + "commander": "^3.0.1", + "cucumber-expressions": "^8.1.0", + "cucumber-tag-expressions": "^2.0.2", + "duration": "^0.2.1", + "escape-string-regexp": "^2.0.0", + "figures": "^3.0.0", + "gherkin": "5.0.0", + "glob": "^7.1.3", + "indent-string": "^4.0.0", + "is-generator": "^1.0.2", + "is-stream": "^2.0.0", + "knuth-shuffle-seeded": "^1.0.6", + "lodash": "^4.17.14", + "mz": "^2.4.0", + "progress": "^2.0.0", + "resolve": "^1.3.3", + "serialize-error": "^4.1.0", + "stack-chain": "^2.0.0", + "stacktrace-js": "^2.0.0", + "string-argv": "^0.3.0", + "title-case": "^2.1.1", + "util-arity": "^1.0.2", + "verror": "^1.9.0" + }, + "bin": { + "cucumber-js": "bin/cucumber-js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cucumber-expressions": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/cucumber-expressions/-/cucumber-expressions-8.3.0.tgz", + "integrity": "sha512-cP2ya0EiorwXBC7Ll7Cj7NELYbasNv9Ty42L4u7sso9KruWemWG1ZiTq4PMqir3SNDSrbykoqI5wZgMbLEDjLQ==", + "deprecated": "This package is now published under @cucumber/cucumber-expressions", + "dev": true, + "peer": true, + "dependencies": { + "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0", + "xregexp": "^4.2.4" + } + }, + "node_modules/cucumber-expressions/node_modules/xregexp": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.4.1.tgz", + "integrity": "sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/runtime-corejs3": "^7.12.1" + } + }, + "node_modules/cucumber-pretty": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cucumber-pretty/-/cucumber-pretty-6.0.1.tgz", + "integrity": "sha512-9uOIZ8x3lgCPROqYc7kqe2e7UrH5TZPZCdj5fVPze1XViG9yv8/8MnFsAnVINDYWVhiql8DJHb3UrZfIPHYH/A==", + "dev": true, + "dependencies": { + "cli-table3": "^0.6.0", + "colors": "^1.4.0", + "figures": "^3.2.0" + }, + "peerDependencies": { + "cucumber": ">=6.0.0 <7.0.0" + } + }, + "node_modules/cucumber-tag-expressions": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cucumber-tag-expressions/-/cucumber-tag-expressions-2.0.3.tgz", + "integrity": "sha512-+x5j1IfZrBtbvYHuoUX0rl4nUGxaey6Do9sM0CABmZfDCcWXuuRm1fQeCaklIYQgOFHQ6xOHvDSdkMHHpni6tQ==", + "dev": true, + "peer": true + }, + "node_modules/cucumber-tsflow": { + "version": "4.0.0-preview.7", + "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-preview.7.tgz", + "integrity": "sha512-gG51EelraRDM+B3/tShrs+71/2A20IRblXFGT6W6+5qhEtykep7rYOs+wFL1YQ5FFmGCiZISoRI4KucPgcqhOw==", + "dev": true, + "dependencies": { + "callsites": "^3.1.0", + "log4js": "^6.3.0", + "source-map-support": "^0.5.19", + "underscore": "^1.8.3" + } + }, + "node_modules/cucumber/node_modules/ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/cucumber/node_modules/cli-table3": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", + "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", + "dev": true, + "peer": true, + "dependencies": { + "object-assign": "^4.1.0", + "string-width": "^2.1.1" + }, + "engines": { + "node": ">=6" + }, + "optionalDependencies": { + "colors": "^1.1.2" + } + }, + "node_modules/cucumber/node_modules/commander": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", + "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", + "dev": true, + "peer": true + }, + "node_modules/cucumber/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/cucumber/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/cucumber/node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "peer": true, + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/cucumber/node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "peer": true, + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -2256,15 +2561,6 @@ "node": ">=4.0" } }, - "node_modules/escodegen/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/eslint": { "version": "8.9.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", @@ -3111,6 +3407,17 @@ "assert-plus": "^1.0.0" } }, + "node_modules/gherkin": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-5.0.0.tgz", + "integrity": "sha512-Y+93z2Nh+TNIKuKEf+6M0FQrX/z0Yv9C2LFfc5NlcGJWRrrTeI/jOg2374y1FOw6ZYQ3RgJBezRkli7CLDubDA==", + "deprecated": "This package is now published under @cucumber/gherkin", + "dev": true, + "peer": true, + "bin": { + "gherkin-javascript": "bin/gherkin" + } + }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -4189,15 +4496,6 @@ "karma": ">=0.9" } }, - "node_modules/karma/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/kew": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", @@ -5485,6 +5783,13 @@ "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", "dev": true }, + "node_modules/regenerator-runtime": { + "version": "0.13.10", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", + "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==", + "dev": true, + "peer": true + }, "node_modules/regexp-match-indices": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regexp-match-indices/-/regexp-match-indices-1.0.2.tgz", @@ -5780,6 +6085,29 @@ "integrity": "sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ=", "dev": true }, + "node_modules/serialize-error": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", + "integrity": "sha512-5j9GgyGsP9vV9Uj1S0lDCvlsd+gc2LEPVK7HHHte7IyPwOD4lVQFeaX143gx3U5AnoCi+wbcb3mvaxVysjpxEw==", + "dev": true, + "peer": true, + "dependencies": { + "type-fest": "^0.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/serialize-error/node_modules/type-fest": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", + "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=6" + } + }, "node_modules/serialize-javascript": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", @@ -6013,25 +6341,25 @@ "node": ">= 6" } }, - "node_modules/source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/source-map-support/node_modules/source-map": { + "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/sourcemap-codec": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", @@ -6419,25 +6747,6 @@ "node": ">= 8" } }, - "node_modules/terser/node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/terser/node_modules/source-map-support/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -6471,6 +6780,34 @@ "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "dev": true }, + "node_modules/title-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", + "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", + "dev": true, + "peer": true, + "dependencies": { + "no-case": "^2.2.0", + "upper-case": "^1.0.3" + } + }, + "node_modules/title-case/node_modules/lower-case": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", + "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", + "dev": true, + "peer": true + }, + "node_modules/title-case/node_modules/no-case": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", + "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", + "dev": true, + "peer": true, + "dependencies": { + "lower-case": "^1.1.1" + } + }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -6528,6 +6865,15 @@ "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "dev": true }, + "node_modules/ts-dedent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", + "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", + "dev": true, + "engines": { + "node": ">=6.10" + } + }, "node_modules/ts-mocha": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-9.0.2.tgz", @@ -6590,12 +6936,12 @@ } }, "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -6606,7 +6952,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "bin": { @@ -6760,9 +7106,9 @@ "dev": true }, "node_modules/typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -6803,6 +7149,13 @@ "node": ">= 0.8" } }, + "node_modules/upper-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", + "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", + "dev": true, + "peer": true + }, "node_modules/upper-case-first": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", @@ -6857,9 +7210,9 @@ "dev": true }, "node_modules/v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "node_modules/verror": { @@ -7274,19 +7627,24 @@ "js-tokens": "^4.0.0" } }, - "@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true + "@babel/runtime-corejs3": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.0.tgz", + "integrity": "sha512-v1JH7PeAAGBEyTQM9TqojVl+b20zXtesFKCJHu50xMxZKD1fX0TKaKHPsZfFkXfs7D1M9M6Eeqg1FkJ3a0x2dA==", + "dev": true, + "peer": true, + "requires": { + "core-js-pure": "^3.25.1", + "regenerator-runtime": "^0.13.10" + } }, "@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "requires": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" } }, "@cucumber/create-meta": { @@ -7369,6 +7727,18 @@ "@cucumber/messages": "^16.0.0", "commander": "7.2.0", "source-map-support": "0.5.19" + }, + "dependencies": { + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + } } }, "@cucumber/html-formatter": { @@ -7380,6 +7750,18 @@ "@cucumber/messages": "^16.0.1", "commander": "7.2.0", "source-map-support": "0.5.19" + }, + "dependencies": { + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + } } }, "@cucumber/message-streams": { @@ -7403,6 +7785,26 @@ "uuid": "8.3.2" } }, + "@cucumber/pretty-formatter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", + "integrity": "sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==", + "dev": true, + "requires": { + "ansi-styles": "^5.0.0", + "cli-table3": "^0.6.0", + "figures": "^3.2.0", + "ts-dedent": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true + } + } + }, "@cucumber/tag-expressions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@cucumber/tag-expressions/-/tag-expressions-3.0.1.tgz", @@ -7539,6 +7941,28 @@ } } }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -7697,6 +8121,21 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, + "@types/chai": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", + "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", + "dev": true + }, + "@types/cucumber": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/cucumber/-/cucumber-7.0.0.tgz", + "integrity": "sha512-cr5NN8/jmbw3vDKTQfGW0cSzDtkvxixu9bUD6po9U6OEF04XLuukTDldFG34ccDscLkA8bYnZ7VjxP79cIC7tg==", + "dev": true, + "requires": { + "@cucumber/cucumber": "*" + } + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -7770,6 +8209,12 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, + "@types/pubnub": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", + "integrity": "sha512-Ui58Xsn8/4Ty1hFW0t91ED6FKezzipjO+GEJviOdJdqp817+I5/WMfo5zBsDfjbZQWMqcdrktMauKpUqiIF1wA==", + "dev": true + }, "@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -8209,6 +8654,13 @@ "tweetnacl": "^0.14.3" } }, + "becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==", + "dev": true, + "peer": true + }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -8583,6 +9035,13 @@ "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" }, + "core-js-pure": { + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", + "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", + "dev": true, + "peer": true + }, "core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -8616,6 +9075,158 @@ } } }, + "cucumber": { + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.7.tgz", + "integrity": "sha512-pN3AgWxHx8rOi+wOlqjASNETOjf3TgeyqhMNLQam7nSTXgQzju1oAmXkleRQRcXvpVvejcDHiZBLFSfBkqbYpA==", + "dev": true, + "peer": true, + "requires": { + "assertion-error-formatter": "^3.0.0", + "bluebird": "^3.4.1", + "cli-table3": "^0.5.1", + "colors": "^1.1.2", + "commander": "^3.0.1", + "cucumber-expressions": "^8.1.0", + "cucumber-tag-expressions": "^2.0.2", + "duration": "^0.2.1", + "escape-string-regexp": "^2.0.0", + "figures": "^3.0.0", + "gherkin": "5.0.0", + "glob": "^7.1.3", + "indent-string": "^4.0.0", + "is-generator": "^1.0.2", + "is-stream": "^2.0.0", + "knuth-shuffle-seeded": "^1.0.6", + "lodash": "^4.17.14", + "mz": "^2.4.0", + "progress": "^2.0.0", + "resolve": "^1.3.3", + "serialize-error": "^4.1.0", + "stack-chain": "^2.0.0", + "stacktrace-js": "^2.0.0", + "string-argv": "^0.3.0", + "title-case": "^2.1.1", + "util-arity": "^1.0.2", + "verror": "^1.9.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "peer": true + }, + "cli-table3": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", + "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", + "dev": true, + "peer": true, + "requires": { + "colors": "^1.1.2", + "object-assign": "^4.1.0", + "string-width": "^2.1.1" + } + }, + "commander": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", + "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", + "dev": true, + "peer": true + }, + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "peer": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true, + "peer": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "peer": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "peer": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "cucumber-expressions": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/cucumber-expressions/-/cucumber-expressions-8.3.0.tgz", + "integrity": "sha512-cP2ya0EiorwXBC7Ll7Cj7NELYbasNv9Ty42L4u7sso9KruWemWG1ZiTq4PMqir3SNDSrbykoqI5wZgMbLEDjLQ==", + "dev": true, + "peer": true, + "requires": { + "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0", + "xregexp": "^4.2.4" + }, + "dependencies": { + "xregexp": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.4.1.tgz", + "integrity": "sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==", + "dev": true, + "peer": true, + "requires": { + "@babel/runtime-corejs3": "^7.12.1" + } + } + } + }, + "cucumber-pretty": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cucumber-pretty/-/cucumber-pretty-6.0.1.tgz", + "integrity": "sha512-9uOIZ8x3lgCPROqYc7kqe2e7UrH5TZPZCdj5fVPze1XViG9yv8/8MnFsAnVINDYWVhiql8DJHb3UrZfIPHYH/A==", + "dev": true, + "requires": { + "cli-table3": "^0.6.0", + "colors": "^1.4.0", + "figures": "^3.2.0" + } + }, + "cucumber-tag-expressions": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cucumber-tag-expressions/-/cucumber-tag-expressions-2.0.3.tgz", + "integrity": "sha512-+x5j1IfZrBtbvYHuoUX0rl4nUGxaey6Do9sM0CABmZfDCcWXuuRm1fQeCaklIYQgOFHQ6xOHvDSdkMHHpni6tQ==", + "dev": true, + "peer": true + }, + "cucumber-tsflow": { + "version": "4.0.0-preview.7", + "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-preview.7.tgz", + "integrity": "sha512-gG51EelraRDM+B3/tShrs+71/2A20IRblXFGT6W6+5qhEtykep7rYOs+wFL1YQ5FFmGCiZISoRI4KucPgcqhOw==", + "dev": true, + "requires": { + "callsites": "^3.1.0", + "log4js": "^6.3.0", + "source-map-support": "^0.5.19", + "underscore": "^1.8.3" + } + }, "custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -8983,12 +9594,6 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true } } }, @@ -9649,6 +10254,13 @@ "assert-plus": "^1.0.0" } }, + "gherkin": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-5.0.0.tgz", + "integrity": "sha512-Y+93z2Nh+TNIKuKEf+6M0FQrX/z0Yv9C2LFfc5NlcGJWRrrTeI/jOg2374y1FOw6ZYQ3RgJBezRkli7CLDubDA==", + "dev": true, + "peer": true + }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -10410,14 +11022,6 @@ "tmp": "0.2.1", "ua-parser-js": "0.7.22", "yargs": "^15.3.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } } }, "karma-chai": { @@ -11464,6 +12068,13 @@ "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", "dev": true }, + "regenerator-runtime": { + "version": "0.13.10", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", + "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==", + "dev": true, + "peer": true + }, "regexp-match-indices": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regexp-match-indices/-/regexp-match-indices-1.0.2.tgz", @@ -11678,6 +12289,25 @@ "integrity": "sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ=", "dev": true }, + "serialize-error": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", + "integrity": "sha512-5j9GgyGsP9vV9Uj1S0lDCvlsd+gc2LEPVK7HHHte7IyPwOD4lVQFeaX143gx3U5AnoCi+wbcb3mvaxVysjpxEw==", + "dev": true, + "peer": true, + "requires": { + "type-fest": "^0.3.0" + }, + "dependencies": { + "type-fest": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", + "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", + "dev": true, + "peer": true + } + } + }, "serialize-javascript": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", @@ -11891,22 +12521,20 @@ "socks": "^2.3.3" } }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "devOptional": true + }, "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } } }, "sourcemap-codec": { @@ -12213,24 +12841,6 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", "dev": true - }, - "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } } } }, @@ -12264,6 +12874,36 @@ "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "dev": true }, + "title-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", + "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", + "dev": true, + "peer": true, + "requires": { + "no-case": "^2.2.0", + "upper-case": "^1.0.3" + }, + "dependencies": { + "lower-case": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", + "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", + "dev": true, + "peer": true + }, + "no-case": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", + "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", + "dev": true, + "peer": true, + "requires": { + "lower-case": "^1.1.1" + } + } + } + }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -12309,6 +12949,12 @@ "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "dev": true }, + "ts-dedent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", + "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", + "dev": true + }, "ts-mocha": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-9.0.2.tgz", @@ -12350,12 +12996,12 @@ } }, "ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "requires": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -12366,7 +13012,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" } }, @@ -12475,9 +13121,9 @@ "dev": true }, "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true }, "ua-parser-js": { @@ -12502,6 +13148,13 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, + "upper-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", + "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", + "dev": true, + "peer": true + }, "upper-case-first": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", @@ -12550,9 +13203,9 @@ "dev": true }, "v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "verror": { diff --git a/package.json b/package.json index dbaae11d3..4817121cb 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "ci:node": "npm run clean && npm run build && npm run lint && npm run test:node", "test:feature:objectsv2:node": "ts-mocha -p tsconfig.mocha.json --no-config --require test/setup.js --reporter spec test/dist/objectsv2.test.js", "test:feature:fileupload:node": "ts-mocha -p tsconfig.mocha.json --no-config --require test/setup.js --reporter spec test/feature/file_upload.node.test.js", + "test:contract": "npm run test:contract:prepare && npm run test:contract:start", + "test:contract:prepare": "rimraf test/specs && git clone --branch master git@github.com:pubnub/sdk-specifications.git test/specs", + "test:contract:start": "cucumber-js -p default --tags 'not @na=js and not @beta and not @skip'", "contract:refresh": "rimraf dist/contract && git clone --branch master git@github.com:pubnub/service-contract-mock.git dist/contract && npm install --prefix dist/contract && npm run refresh-files --prefix dist/contract", "contract:server": "npm start --prefix dist/contract consumer", "contract:build": "cd test/contract && tsc", @@ -57,18 +60,24 @@ }, "devDependencies": { "@cucumber/cucumber": "^7.3.1", + "@cucumber/pretty-formatter": "^1.0.0", "@rollup/plugin-commonjs": "^21.0.2", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.1.3", "@rollup/plugin-typescript": "^8.3.1", + "@types/chai": "^4.3.3", + "@types/cucumber": "^7.0.0", "@types/expect": "^24.3.0", "@types/mocha": "^9.1.0", "@types/nock": "^9.3.1", + "@types/pubnub": "^7.2.0", "@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/parser": "^5.12.1", - "chai": "4.3.4", + "chai": "^4.3.4", "chai-as-promised": "^7.1.1", "chai-nock": "^1.2.0", + "cucumber-pretty": "^6.0.1", + "cucumber-tsflow": "^4.0.0-preview.7", "es6-shim": "^0.35.6", "eslint": "^8.9.0", "eslint-plugin-mocha": "^10.0.3", @@ -93,9 +102,10 @@ "rollup-plugin-terser": "^7.0.2", "sinon": "^7.5.0", "sinon-chai": "^3.3.0", + "source-map-support": "^0.5.21", "ts-mocha": "^9.0.2", - "ts-node": "^10.7.0", - "typescript": "^4.3.5", + "ts-node": "^10.9.1", + "typescript": "^4.8.4", "underscore": "^1.9.2" }, "license": "MIT", diff --git a/src/core/components/_endpoint.ts b/src/core/components/_endpoint.ts new file mode 100644 index 000000000..66476c29f --- /dev/null +++ b/src/core/components/_endpoint.ts @@ -0,0 +1,24 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { Operation } from '../constants/operations'; + +type Modules = { + config: any; +}; + +export type Endpoint = { + getOperation(): Operation | string; + getRequestTimeout(modules: Modules): number; + isAuthSupported(): boolean; + + validateParams(modules: Modules, params: P): string | void; + + usePost?(modules: Modules, params: P): boolean; + + getURL?(modules: Modules, params: P): string; + postURL?(modules: Modules, params: P): string; + + prepareParams?(modules: Modules, params: P): Record; + postPayload?(modules: Modules, params: P): unknown; + + handleResponse(modules: Modules, response: any): R; +}; diff --git a/src/core/constants/operations.ts b/src/core/constants/operations.ts new file mode 100644 index 000000000..75e1467d0 --- /dev/null +++ b/src/core/constants/operations.ts @@ -0,0 +1,164 @@ +export enum Operation { + Time = 'PNTimeOperation', + + History = 'PNHistoryOperation', + DeleteMessages = 'PNDeleteMessagesOperation', + FetchMessages = 'PNFetchMessagesOperation', + MessageCounts = 'PNMessageCountsOperation', + + Subscribe = 'PNSubscribeOperation', + Unsubscribe = 'PNUnsubscribeOperation', + Publish = 'PNPublishOperation', + Signal = 'PNSignalOperation', + + AddMessageAction = 'PNAddActionOperation', + RemoveMessageAction = 'PNRemoveMessageActionOperation', + GetMessageActions = 'PNGetMessageActionsOperation', + + CreateUser = 'PNCreateUserOperation', + UpdateUser = 'PNUpdateUserOperation', + RemoveUser = 'PNRemoveUserOperation', + FetchUser = 'PNFetchUserOperation', + GetUsers = 'PNGetUsersOperation', + CreateSpace = 'PNCreateSpaceOperation', + UpdateSpace = 'PNUpdateSpaceOperation', + RemoveSpace = 'PNRemoveSpaceOperation', + FetchSpace = 'PNFetchSpaceOperation', + GetSpaces = 'PNGetSpacesOperation', + GetMembers = 'PNGetMembersOperation', + UpdateMembers = 'PNUpdateMembersOperation', + GetMemberships = 'PNGetMembershipsOperation', + UpdateMemberships = 'PNUpdateMembershipsOperation', + + ListFiles = 'PNListFilesOperation', + GenerateUploadUrl = 'PNGenerateUploadUrlOperation', + PublishFile = 'PNPublishFileOperation', + GetFileUrl = 'PNGetFileUrlOperation', + DownloadFile = 'PNDownloadFileOperation', + + GetAllUUIDMetadata = 'PNGetAllUUIDMetadataOperation', + GetUUIDMetadata = 'PNGetUUIDMetadataOperation', + SetUUIDMetadata = 'PNSetUUIDMetadataOperation', + RemoveUUIDMetadata = 'PNRemoveUUIDMetadataOperation', + GetAllChannelMetadata = 'PNGetAllChannelMetadataOperation', + GetChannelMetadata = 'PNGetChannelMetadataOperation', + SetChannelMetadata = 'PNSetChannelMetadataOperation', + RemoveChannelMetadata = 'PNRemoveChannelMetadataOperation', + SetMembers = 'PNSetMembersOperation', + SetMemberships = 'PNSetMembershipsOperation', + + PushNotificationEnabledChannels = 'PNPushNotificationEnabledChannelsOperation', + RemoveAllPushNotifications = 'PNRemoveAllPushNotificationsOperation', + + WhereNow = 'PNWhereNowOperation', + SetState = 'PNSetStateOperation', + HereNow = 'PNHereNowOperation', + GetState = 'PNGetStateOperation', + Heartbeat = 'PNHeartbeatOperation', + + ChannelGroups = 'PNChannelGroupsOperation', + RemoveGroup = 'PNRemoveGroupOperation', + ChannelsForGroup = 'PNChannelsForGroupOperation', + AddChannelsToGroup = 'PNAddChannelsToGroupOperation', + RemoveChannelsFromGroup = 'PNRemoveChannelsFromGroupOperation', + + AccessManagerGrant = 'PNAccessManagerGrant', + AccessManagerGrantToken = 'PNAccessManagerGrantToken', + AccessManagerAudit = 'PNAccessManagerAudit', + AccessManagerRevokeToken = 'PNAccessManagerRevokeToken', + + Handshake = 'PNHandshakeOperation', + ReceiveMessages = 'PNReceiveMessagesOperation', +} + +export default { + PNTimeOperation: 'PNTimeOperation', + + PNHistoryOperation: 'PNHistoryOperation', + PNDeleteMessagesOperation: 'PNDeleteMessagesOperation', + PNFetchMessagesOperation: 'PNFetchMessagesOperation', + PNMessageCounts: 'PNMessageCountsOperation', + + // pubsub + PNSubscribeOperation: 'PNSubscribeOperation', + PNUnsubscribeOperation: 'PNUnsubscribeOperation', + PNPublishOperation: 'PNPublishOperation', + PNSignalOperation: 'PNSignalOperation', + + // Actions API + PNAddMessageActionOperation: 'PNAddActionOperation', + PNRemoveMessageActionOperation: 'PNRemoveMessageActionOperation', + PNGetMessageActionsOperation: 'PNGetMessageActionsOperation', + + // Objects API + PNCreateUserOperation: 'PNCreateUserOperation', + PNUpdateUserOperation: 'PNUpdateUserOperation', + PNRemoveUserOperation: 'PNRemoveUserOperation', + PNFetchUserOperation: 'PNFetchUserOperation', + PNGetUsersOperation: 'PNGetUsersOperation', + PNCreateSpaceOperation: 'PNCreateSpaceOperation', + PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', + PNRemoveSpaceOperation: 'PNRemoveSpaceOperation', + PNFetchSpaceOperation: 'PNFetchSpaceOperation', + PNGetSpacesOperation: 'PNGetSpacesOperation', + PNGetMembersOperation: 'PNGetMembersOperation', + PNUpdateMembersOperation: 'PNUpdateMembersOperation', + PNGetMembershipsOperation: 'PNGetMembershipsOperation', + PNUpdateMembershipsOperation: 'PNUpdateMembershipsOperation', + + // File Upload API v1 + PNListFilesOperation: 'PNListFilesOperation', + PNGenerateUploadUrlOperation: 'PNGenerateUploadUrlOperation', + PNPublishFileOperation: 'PNPublishFileOperation', + PNGetFileUrlOperation: 'PNGetFileUrlOperation', + PNDownloadFileOperation: 'PNDownloadFileOperation', + + // Objects API v2 + // UUID + PNGetAllUUIDMetadataOperation: 'PNGetAllUUIDMetadataOperation', + PNGetUUIDMetadataOperation: 'PNGetUUIDMetadataOperation', + PNSetUUIDMetadataOperation: 'PNSetUUIDMetadataOperation', + PNRemoveUUIDMetadataOperation: 'PNRemoveUUIDMetadataOperation', + // channel + PNGetAllChannelMetadataOperation: 'PNGetAllChannelMetadataOperation', + PNGetChannelMetadataOperation: 'PNGetChannelMetadataOperation', + PNSetChannelMetadataOperation: 'PNSetChannelMetadataOperation', + PNRemoveChannelMetadataOperation: 'PNRemoveChannelMetadataOperation', + // member + // PNGetMembersOperation: 'PNGetMembersOperation', + PNSetMembersOperation: 'PNSetMembersOperation', + // PNGetMembershipsOperation: 'PNGetMembersOperation', + PNSetMembershipsOperation: 'PNSetMembershipsOperation', + + // push + PNPushNotificationEnabledChannelsOperation: 'PNPushNotificationEnabledChannelsOperation', + PNRemoveAllPushNotificationsOperation: 'PNRemoveAllPushNotificationsOperation', + // + + // presence + PNWhereNowOperation: 'PNWhereNowOperation', + PNSetStateOperation: 'PNSetStateOperation', + PNHereNowOperation: 'PNHereNowOperation', + PNGetStateOperation: 'PNGetStateOperation', + PNHeartbeatOperation: 'PNHeartbeatOperation', + // + + // channel group + PNChannelGroupsOperation: 'PNChannelGroupsOperation', + PNRemoveGroupOperation: 'PNRemoveGroupOperation', + PNChannelsForGroupOperation: 'PNChannelsForGroupOperation', + PNAddChannelsToGroupOperation: 'PNAddChannelsToGroupOperation', + PNRemoveChannelsFromGroupOperation: 'PNRemoveChannelsFromGroupOperation', + // + + // PAM + PNAccessManagerGrant: 'PNAccessManagerGrant', + PNAccessManagerGrantToken: 'PNAccessManagerGrantToken', + PNAccessManagerAudit: 'PNAccessManagerAudit', + PNAccessManagerRevokeToken: 'PNAccessManagerRevokeToken', + // + + // subscription utilities + PNHandshakeOperation: 'PNHandshakeOperation', + PNReceiveMessagesOperation: 'PNReceiveMessagesOperation', +} as const; diff --git a/src/core/endpoints/user/create.ts b/src/core/endpoints/user/create.ts new file mode 100644 index 000000000..cb0a1e34b --- /dev/null +++ b/src/core/endpoints/user/create.ts @@ -0,0 +1,40 @@ +import { Endpoint } from '../../components/_endpoint'; +import operationConstants from '../../constants/operations'; + +import utils from '../../utils'; + +const endpoint: Endpoint<{ data: any; userId: string }, { status: number; data: any }> = { + getOperation: () => operationConstants.PNCreateUserOperation, + + validateParams: (_, params) => { + if (!params?.data) { + return 'Data cannot be empty'; + } + }, + + usePost: () => true, + + postURL: ({ config }, params) => + `/v3/objects/${config.subscribeKey}/users/${utils.encodeString(params.userId ?? config.getUserId())}`, + + postPayload: (_, params) => params.data, + + getRequestTimeout: ({ config }) => config.getTransactionTimeout(), + + isAuthSupported: () => true, + + prepareParams: ({ config }, params) => { + const queryParams = { + uuid: params?.userId ?? config.getUserId(), + }; + + return queryParams; + }, + + handleResponse: (_, response) => ({ + status: response.status, + data: response.data, + }), +}; + +export default endpoint; diff --git a/src/core/endpoints/user/fetch.ts b/src/core/endpoints/user/fetch.ts new file mode 100644 index 000000000..1e9da8519 --- /dev/null +++ b/src/core/endpoints/user/fetch.ts @@ -0,0 +1,32 @@ +import { Endpoint } from '../../components/_endpoint'; +import operationConstants from '../../constants/operations'; + +import utils from '../../utils'; + +const endpoint: Endpoint<{ userId?: string }, { status: number; data: any }> = { + getOperation: () => operationConstants.PNFetchUserOperation, + + validateParams: () => { + // No required parameters. + }, + + getURL: ({ config }, params) => + `/v3/objects/${config.subscribeKey}/users/${utils.encodeString(params?.userId ?? config.getUserId())}`, + + getRequestTimeout: ({ config }) => config.getTransactionTimeout(), + + isAuthSupported: () => true, + + prepareParams: ({ config }, params) => { + const queryParams = { uuid: params?.userId ?? config.getUserId() }; + + return queryParams; + }, + + handleResponse: (_, response) => ({ + status: response.status, + data: response.data, + }), +}; + +export default endpoint; diff --git a/test/contract/definitions/grant.ts b/test/contract/definitions/grant.ts new file mode 100644 index 000000000..49053f162 --- /dev/null +++ b/test/contract/definitions/grant.ts @@ -0,0 +1,69 @@ +import { binding, given, then, when } from 'cucumber-tsflow'; +import { expect } from 'chai'; + +import { AccessManagerKeyset } from '../shared/keysets'; +import { PubNub, PubNubManager } from '../shared/pubnub'; +import { tokenWithUUIDPatternPermissions } from '../shared/fixtures'; +import { ResourceType, AccessPermission } from '../shared/enums'; + +import { ParsedGrantToken } from 'pubnub'; + +@binding([PubNubManager, AccessManagerKeyset]) +class GrantTokenSteps { + private pubnub?: PubNub; + + private token?: string; + private parsedToken?: ParsedGrantToken; + + constructor(private manager: PubNubManager, private keyset: AccessManagerKeyset) {} + + @given('I have a keyset with access manager enabled') + public useAccessManagerKeyset(): void { + this.pubnub = this.manager.getInstance(this.keyset); + } + + // Given('I have a known token containing an authorized UUID', function () { + // this.token = this.fixtures.tokenWithKnownAuthorizedUUID; + // }); + + // Given('I have a known token containing UUID resource permissions', function () { + // this.token = this.fixtures.tokenWithUUIDResourcePermissions; + // }); + + @given('I have a known token containing UUID pattern Permissions') + public useTokenWithUUIDPatternPermissions() { + this.token = tokenWithUUIDPatternPermissions; + } + + @when('I parse the token') + public parseToken() { + expect(this.token).to.exist; + expect(this.pubnub).to.exist; + + this.parsedToken = this.pubnub!.parseToken(this.token!); + + expect(this.parsedToken).to.not.be.undefined; + } + + private resourceName?: string; + private resourceType?: ResourceType; + + @then('the token has {string} {resource_type} pattern access permissions') + public withPatternAccessPermissions(name: string, type: ResourceType) { + this.resourceName = name; + this.resourceType = type; + + expect(this.parsedToken?.patterns?.[type]).to.exist; + expect(this.parsedToken?.patterns?.[type]?.[name]).to.exist; + } + + @then('token pattern permission {access_permission}') + public hasAccessPermission(permission: AccessPermission) { + expect(this.resourceType).to.exist; + expect(this.resourceName).to.exist; + + expect(this.parsedToken?.patterns?.[this.resourceType!]?.[this.resourceName!]?.[permission]).to.be.true; + } +} + +export = GrantTokenSteps; diff --git a/test/contract/enums.ts b/test/contract/enums.ts deleted file mode 100644 index 8ba2ecbc0..000000000 --- a/test/contract/enums.ts +++ /dev/null @@ -1,15 +0,0 @@ -export enum ACCESS_PERMISSION { - READ = "read", - WRITE = "write", - GET = "get", - MANAGE = "manage", - UPDATE = "update", - JOIN = "join", - DELETE = "delete" -} - -export enum RESOURCE_TYPE { - CHANNEL = "channels", - CHANNEL_GROUP = "groups", - UUID = "uuids" - } \ No newline at end of file diff --git a/test/contract/parameter_types.ts b/test/contract/parameter_types.ts deleted file mode 100644 index 765463889..000000000 --- a/test/contract/parameter_types.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { defineParameterType } from '@cucumber/cucumber'; -import { - RESOURCE_TYPE, - ACCESS_PERMISSION -} from './enums'; - -defineParameterType({ - name: 'resource_type', - regexp: new RegExp(Object.keys(RESOURCE_TYPE).join("|")), - transformer: enum_value => RESOURCE_TYPE[enum_value] -}); - -defineParameterType({ - name: 'access_permission', - regexp: new RegExp(Object.keys(ACCESS_PERMISSION).join("|")), - transformer: enum_value => ACCESS_PERMISSION[enum_value] -}); \ No newline at end of file diff --git a/test/contract/setup.js b/test/contract/setup.js new file mode 100644 index 000000000..3280bec09 --- /dev/null +++ b/test/contract/setup.js @@ -0,0 +1,11 @@ +require('ts-node').register({ + compilerOptions: { + module: 'commonjs', + resolveJsonModule: true, + moduleResolution: 'node', + experimentalDecorators: true, + target: 'es5', + sourceMap: true, + esModuleInterop: true, + }, +}); diff --git a/test/contract/shared/enums.ts b/test/contract/shared/enums.ts new file mode 100644 index 000000000..0c5695655 --- /dev/null +++ b/test/contract/shared/enums.ts @@ -0,0 +1,37 @@ +import { defineParameterType } from '@cucumber/cucumber'; + +export enum AccessPermission { + read = 'read', + write = 'write', + get = 'get', + manage = 'manage', + update = 'update', + join = 'join', + delete = 'delete', +} + +defineParameterType({ + name: 'access_permission', + regexp: new RegExp( + Object.keys(AccessPermission) + .map((key) => key.toUpperCase()) + .join('|'), + ), + transformer: (enum_value) => AccessPermission[enum_value.toLowerCase() as keyof typeof AccessPermission], +}); + +export enum ResourceType { + channel = 'channels', + channelGroup = 'groups', + uuid = 'uuids', +} + +defineParameterType({ + name: 'resource_type', + regexp: new RegExp( + Object.keys(ResourceType) + .map((key) => key.toUpperCase()) + .join('|'), + ), + transformer: (enum_value) => ResourceType[enum_value.toLowerCase() as keyof typeof ResourceType], +}); diff --git a/test/contract/shared/fixtures.ts b/test/contract/shared/fixtures.ts new file mode 100644 index 000000000..a52ce325c --- /dev/null +++ b/test/contract/shared/fixtures.ts @@ -0,0 +1,8 @@ +export const tokenWithKnownAuthorizedUUID = + 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc'; + +export const tokenWithUUIDResourcePermissions = + 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc'; + +export const tokenWithUUIDPatternPermissions = + 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc'; diff --git a/test/contract/shared/keysets.ts b/test/contract/shared/keysets.ts new file mode 100644 index 000000000..8943494cf --- /dev/null +++ b/test/contract/shared/keysets.ts @@ -0,0 +1,5 @@ +export class AccessManagerKeyset { + publishKey = process.env.PUBLISH_KEY_ACCESS || 'pub-key'; + subscribeKey = process.env.SUBSCRIBE_KEY_ACCESS || 'sub-key'; + secretKey = process.env.SECRET_KEY_ACCESS || 'secret-key'; +} diff --git a/test/contract/shared/pubnub.ts b/test/contract/shared/pubnub.ts new file mode 100644 index 000000000..21c23075e --- /dev/null +++ b/test/contract/shared/pubnub.ts @@ -0,0 +1,31 @@ +import type PubNubType from 'pubnub'; +import PubNub from '../../../lib/node/index.js'; + +export interface Keyset { + subscribeKey?: string; + publishKey?: string; +} + +export interface Config extends Keyset { + origin?: string; + ssl?: boolean; + suppressLeaveEvents?: boolean; + logVerbosity?: boolean; + uuid?: string; +} + +const defaultConfig: Config = { + origin: 'localhost:8090', + ssl: false, + suppressLeaveEvents: true, + logVerbosity: false, + uuid: 'myUUID', +}; + +export class PubNubManager { + getInstance(config: Config = {}) { + return new (PubNub as any)({ ...defaultConfig, ...config }); + } +} + +export type PubNub = PubNubType; diff --git a/test/contract/tsconfig.json b/test/contract/tsconfig.json index 40b25e11d..285ad6100 100644 --- a/test/contract/tsconfig.json +++ b/test/contract/tsconfig.json @@ -1,10 +1,11 @@ { - "extends": "@tsconfig/node12/tsconfig.json", - "compilerOptions": { - "preserveConstEnums": true, - "noImplicitAny": false, - "outDir": "../../dist/cucumber/" - }, - "include": ["**/*"], - "exclude": ["node_modules"] - } \ No newline at end of file + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "experimentalDecorators": true, + "target": "es5", + "sourceMap": true, + "esModuleInterop": true + } +} diff --git a/test/contract/cucumber.ts b/test/old_contract/cucumber.ts similarity index 100% rename from test/contract/cucumber.ts rename to test/old_contract/cucumber.ts diff --git a/test/contract/hooks.ts b/test/old_contract/hooks.ts similarity index 67% rename from test/contract/hooks.ts rename to test/old_contract/hooks.ts index 3829cbe14..1472fe4cf 100644 --- a/test/contract/hooks.ts +++ b/test/old_contract/hooks.ts @@ -1,14 +1,14 @@ -import { Before, After, AfterStep } from '@cucumber/cucumber'; +import { Before, After, AfterStep, ITestCaseHookParameter } from '@cucumber/cucumber'; import * as http from 'http'; const mockServerScriptFileTagPrefix = '@contract='; /** * this is run before each scenario - * + * * check if scenario tag includes a script file * call init endpoint on mock server */ -Before(async function (scenario) { +Before(async function (scenario: ITestCaseHookParameter) { let scriptFile = checkMockServerScriptFile(scenario); if (scriptFile) { @@ -20,7 +20,7 @@ Before(async function (scenario) { } }); -After(async function (scenario) { +After(async function (scenario: ITestCaseHookParameter) { let scriptFile = checkMockServerScriptFile(scenario); this.stopPubnub(); @@ -28,36 +28,33 @@ After(async function (scenario) { if (scriptFile && this.settings.checkContractExpectations) { const contractResult = await this.checkContract(); - if ( - contractResult?.expectations?.pending?.length !== 0 || - contractResult?.expectations?.failed?.length !== 0 - ) { - console.log('Contract Expectations', contractResult?.expectations) + if (contractResult?.expectations?.pending?.length !== 0 || contractResult?.expectations?.failed?.length !== 0) { + console.log('Contract Expectations', contractResult?.expectations); throw new Error(`The scenario failed due to contract server expectations [${scenario.pickle.name}]`); } } }); -AfterStep(async function (scenario) { +AfterStep(async function (scenario: ITestCaseHookParameter) { let scriptFile = checkMockServerScriptFile(scenario); if (scriptFile && this.settings.checkContractExpectations) { const contractResult = await this.checkContract(); if (contractResult?.expectations?.failed?.length !== 0) { - throw new Error("The step failed due to contract server expectations."); + throw new Error('The step failed due to contract server expectations.'); } } }); -function checkMockServerScriptFile(scenario) { - let mockServerFileName; +function checkMockServerScriptFile(scenario: ITestCaseHookParameter) { + let mockServerFileName: string | undefined; - scenario.pickle.tags.forEach(tag => { + for (const tag of scenario.pickle.tags) { if (tag.name.indexOf(mockServerScriptFileTagPrefix) === 0) { mockServerFileName = tag.name.substring(mockServerScriptFileTagPrefix.length); } - }); - + } + return mockServerFileName; -} \ No newline at end of file +} diff --git a/test/old_contract/parameter_types.ts b/test/old_contract/parameter_types.ts new file mode 100644 index 000000000..5ffdb6d22 --- /dev/null +++ b/test/old_contract/parameter_types.ts @@ -0,0 +1,14 @@ +import { defineParameterType } from '@cucumber/cucumber'; +import { ResourceType, AccessPermission } from '../contract/shared/enums'; + +defineParameterType({ + name: 'resource_type', + regexp: new RegExp(Object.keys(ResourceType).join('|')), + transformer: (enum_value) => ResourceType[enum_value as keyof typeof ResourceType], +}); + +defineParameterType({ + name: 'access_permission', + regexp: new RegExp(Object.keys(AccessPermission).join('|')), + transformer: (enum_value) => AccessPermission[enum_value as keyof typeof AccessPermission], +}); diff --git a/test/contract/steps/access/auth.ts b/test/old_contract/steps/access/auth.ts similarity index 100% rename from test/contract/steps/access/auth.ts rename to test/old_contract/steps/access/auth.ts diff --git a/test/contract/steps/access/grant_token.ts b/test/old_contract/steps/access/grant_token.ts similarity index 61% rename from test/contract/steps/access/grant_token.ts rename to test/old_contract/steps/access/grant_token.ts index fc53e7ee9..83a780bc5 100644 --- a/test/contract/steps/access/grant_token.ts +++ b/test/old_contract/steps/access/grant_token.ts @@ -1,9 +1,6 @@ import { Given, When, Then, Before, After } from '@cucumber/cucumber'; import { expect } from 'chai'; -import { - ACCESS_PERMISSION, - RESOURCE_TYPE -} from '../../enums.js'; +import { AccessPermission, ResourceType } from '../../../contract/shared/enums.js'; // Before({ tags: '@contract=grantAllPermissions' }, function () { // this.grantPayload = {}; @@ -13,59 +10,66 @@ Before(function () { this.grantPayload = {}; }); -Given('I have a keyset with access manager enabled', function() { +Given('I have a keyset with access manager enabled', function () { + console.log(this); this.keyset = this.fixtures.accessManagerKeyset; }); -Given('the authorized UUID {string}', function(uuid: string) { +Given('the authorized UUID {string}', function (uuid: string) { this.grantPayload.authorized_uuid = uuid; }); -Given('the TTL {int}', function(ttl: number) { +Given('the TTL {int}', function (ttl: number) { this.grantPayload.ttl = ttl; }); -Given('the {string} {resource_type} resource access permissions', function(resourceName: string, resourceType: RESOURCE_TYPE) { - this.resourceName = resourceName; - this.resourceType = resourceType; - - this.grantPayload.resources = this.grantPayload.resources || {}; - this.grantPayload.resources[this.resourceType] = this.grantPayload.resources[this.resourceType] || {}; +Given( + 'the {string} {resource_type} resource access permissions', + function (resourceName: string, resourceType: ResourceType) { + this.resourceName = resourceName; + this.resourceType = resourceType; - this.grantPayload.resources[this.resourceType][this.resourceName] = {}; -}); + this.grantPayload.resources = this.grantPayload.resources || {}; + this.grantPayload.resources[this.resourceType] = this.grantPayload.resources[this.resourceType] || {}; -Given('the {string} {resource_type} pattern access permissions', function(resourceName: string, resourceType: RESOURCE_TYPE) { - this.resourceName = resourceName; - this.resourceType = resourceType; + this.grantPayload.resources[this.resourceType][this.resourceName] = {}; + }, +); - this.grantPayload.patterns = this.grantPayload.patterns || {}; - this.grantPayload.patterns[this.resourceType] = this.grantPayload.patterns[this.resourceType] || {}; +Given( + 'the {string} {resource_type} pattern access permissions', + function (resourceName: string, resourceType: ResourceType) { + this.resourceName = resourceName; + this.resourceType = resourceType; - this.grantPayload.patterns[this.resourceType][this.resourceName] = {}; -}); + this.grantPayload.patterns = this.grantPayload.patterns || {}; + this.grantPayload.patterns[this.resourceType] = this.grantPayload.patterns[this.resourceType] || {}; + + this.grantPayload.patterns[this.resourceType][this.resourceName] = {}; + }, +); -Given('grant resource permission {access_permission}', function(accessPermission: ACCESS_PERMISSION) { +Given('grant resource permission {access_permission}', function (accessPermission: AccessPermission) { this.grantPayload.resources[this.resourceType][this.resourceName][accessPermission] = true; }); -Given('deny resource permission {access_permission}', function(accessPermission: ACCESS_PERMISSION) { +Given('deny resource permission {access_permission}', function (accessPermission: AccessPermission) { this.grantPayload.resources[this.resourceType][this.resourceName][accessPermission] = false; }); -Given('grant pattern permission {access_permission}', function(accessPermission: ACCESS_PERMISSION) { +Given('grant pattern permission {access_permission}', function (accessPermission: AccessPermission) { this.grantPayload.patterns[this.resourceType][this.resourceName][accessPermission] = true; }); -Given('deny pattern permission {access_permission}', function(accessPermission: ACCESS_PERMISSION) { +Given('deny pattern permission {access_permission}', function (accessPermission: AccessPermission) { this.grantPayload.patterns[this.resourceType][this.resourceName][accessPermission] = false; }); -When('I grant a token specifying those permissions', async function() { +When('I grant a token specifying those permissions', async function () { const pubnub = await this.getPubnub({ publishKey: this.keyset.publishKey, subscribeKey: this.keyset.subscribeKey, - secretKey: this.keyset.secretKey + secretKey: this.keyset.secretKey, }); this.token = await pubnub.grantToken(this.grantPayload); @@ -76,11 +80,11 @@ When('I grant a token specifying those permissions', async function() { // console.log('parsed token', JSON.stringify(this.parsedToken, null, 2)); }); -When('I attempt to grant a token specifying those permissions', async function() { +When('I attempt to grant a token specifying those permissions', async function () { const pubnub = await this.getPubnub({ publishKey: this.keyset.publishKey, subscribeKey: this.keyset.subscribeKey, - secretKey: this.keyset.secretKey + secretKey: this.keyset.secretKey, }); try { @@ -93,34 +97,40 @@ When('I attempt to grant a token specifying those permissions', async function() expect(this.expectedError).not.to.be.undefined; }); -Then('the token contains the TTL {int}', function(ttl: number) { +Then('the token contains the TTL {int}', function (ttl: number) { expect(this.parsedToken.ttl).to.equal(ttl); }); -Then('the token contains the authorized UUID {string}', function(uuid: string) { +Then('the token contains the authorized UUID {string}', function (uuid: string) { expect(this.parsedToken.authorized_uuid).to.equal(uuid); }); -Then('the token has {string} {resource_type} resource access permissions', function(resourceName: string, resourceType: RESOURCE_TYPE) { - this.resourceName = resourceName; - this.resourceType = resourceType; - expect(this.parsedToken.resources[this.resourceType]).to.exist; - expect(this.parsedToken.resources[this.resourceType][this.resourceName]).to.exist; -}); - -Then('the token has {string} {resource_type} pattern access permissions', function(resourceName: string, resourceType: RESOURCE_TYPE) { - this.resourceName = resourceName; - this.resourceType = resourceType; - - expect(this.parsedToken.patterns[this.resourceType]).to.exist; - expect(this.parsedToken.patterns[this.resourceType][this.resourceName]).to.exist; -}); - -Then('token resource permission {access_permission}', function(accessPermission: ACCESS_PERMISSION) { +Then( + 'the token has {string} {resource_type} resource access permissions', + function (resourceName: string, resourceType: ResourceType) { + this.resourceName = resourceName; + this.resourceType = resourceType; + expect(this.parsedToken.resources[this.resourceType]).to.exist; + expect(this.parsedToken.resources[this.resourceType][this.resourceName]).to.exist; + }, +); + +Then( + 'the token has {string} {resource_type} pattern access permissions', + function (resourceName: string, resourceType: ResourceType) { + this.resourceName = resourceName; + this.resourceType = resourceType; + + expect(this.parsedToken.patterns[this.resourceType]).to.exist; + expect(this.parsedToken.patterns[this.resourceType][this.resourceName]).to.exist; + }, +); + +Then('token resource permission {access_permission}', function (accessPermission: AccessPermission) { expect(this.parsedToken.resources[this.resourceType][this.resourceName][accessPermission]).to.be.true; }); -Then('token pattern permission {access_permission}', function(accessPermission: ACCESS_PERMISSION) { +Then('token pattern permission {access_permission}', function (accessPermission: AccessPermission) { expect(this.parsedToken.patterns[this.resourceType][this.resourceName][accessPermission]).to.be.true; }); @@ -132,10 +142,10 @@ Then('an error is returned', function () { expect(this.expectedError.status).to.be.a('number'); expect(this.expectedError.error).to.be.an('object'); - expect(this.expectedError.error).to.have.keys([ 'message', 'source', 'details' ]); - + expect(this.expectedError.error).to.have.keys(['message', 'source', 'details']); + expect(this.expectedError.error.message).to.be.a('string'); - + expect(this.expectedError.error.source).to.be.a('string'); expect(this.expectedError.error.details).to.be.an('array'); @@ -144,7 +154,7 @@ Then('an error is returned', function () { let details = this.expectedError.error.details[0]; expect(details).to.be.an('object'); - expect(details).to.have.keys([ 'message', 'location', 'locationType' ]); + expect(details).to.have.keys(['message', 'location', 'locationType']); expect(details.message).to.be.a('string'); expect(details.location).to.be.a('string'); @@ -187,28 +197,28 @@ Then('the error detail location type is {string}', function (errorLocationType: expect(details.locationType).to.equal(errorLocationType); }); -Given('I have a known token containing an authorized UUID', function() { +Given('I have a known token containing an authorized UUID', function () { this.token = this.fixtures.tokenWithKnownAuthorizedUUID; }); -Given('I have a known token containing UUID resource permissions', function() { +Given('I have a known token containing UUID resource permissions', function () { this.token = this.fixtures.tokenWithUUIDResourcePermissions; }); -Given('I have a known token containing UUID pattern Permissions', function() { +Given('I have a known token containing UUID pattern Permissions', function () { this.token = this.fixtures.tokenWithUUIDPatternPermissions; }); -When('I parse the token', function() { +When('I parse the token', function () { expect(this.token).not.to.be.empty; let pubnub = this.getPubnub({ publishKey: this.keyset.publishKey, - subscribeKey: this.keyset.subscribeKey + subscribeKey: this.keyset.subscribeKey, }); this.parsedToken = pubnub.parseToken(this.token); }); -Then('the parsed token output contains the authorized UUID {string}', function(uuid) { +Then('the parsed token output contains the authorized UUID {string}', function (uuid) { expect(this.parsedToken).to.exist; expect(this.parsedToken.authorized_uuid).to.equal(uuid); }); diff --git a/test/contract/steps/access/revoke_token.ts b/test/old_contract/steps/access/revoke_token.ts similarity index 100% rename from test/contract/steps/access/revoke_token.ts rename to test/old_contract/steps/access/revoke_token.ts diff --git a/test/contract/steps/common.ts b/test/old_contract/steps/common.ts similarity index 100% rename from test/contract/steps/common.ts rename to test/old_contract/steps/common.ts diff --git a/test/contract/steps/objectsv2/channel.ts b/test/old_contract/steps/objectsv2/channel.ts similarity index 100% rename from test/contract/steps/objectsv2/channel.ts rename to test/old_contract/steps/objectsv2/channel.ts diff --git a/test/contract/steps/objectsv2/channel_member.ts b/test/old_contract/steps/objectsv2/channel_member.ts similarity index 100% rename from test/contract/steps/objectsv2/channel_member.ts rename to test/old_contract/steps/objectsv2/channel_member.ts diff --git a/test/contract/steps/objectsv2/membership.ts b/test/old_contract/steps/objectsv2/membership.ts similarity index 100% rename from test/contract/steps/objectsv2/membership.ts rename to test/old_contract/steps/objectsv2/membership.ts diff --git a/test/contract/steps/objectsv2/uuid.ts b/test/old_contract/steps/objectsv2/uuid.ts similarity index 100% rename from test/contract/steps/objectsv2/uuid.ts rename to test/old_contract/steps/objectsv2/uuid.ts diff --git a/test/contract/steps/subscribe/simple-subscribe.ts b/test/old_contract/steps/subscribe/simple-subscribe.ts similarity index 65% rename from test/contract/steps/subscribe/simple-subscribe.ts rename to test/old_contract/steps/subscribe/simple-subscribe.ts index 2af52c719..4b4742d40 100644 --- a/test/contract/steps/subscribe/simple-subscribe.ts +++ b/test/old_contract/steps/subscribe/simple-subscribe.ts @@ -1,50 +1,52 @@ import { When, Then } from '@cucumber/cucumber'; import { expect } from 'chai'; +import { MessageEvent, StatusEvent } from 'pubnub'; -When('I subscribe to channel {string}', async function(channel) { +When('I subscribe to channel {string}', async function (channel) { // remember the channel we subscribed to this.channel = channel; let pubnub = this.getPubnub({ - publishKey: this.keyset.publishKey, - subscribeKey: this.keyset.subscribeKey - }); + publishKey: this.keyset.publishKey, + subscribeKey: this.keyset.subscribeKey, + }); - let connectedResponse = new Promise(((resolveConnected) => { - this.subscribeResponse = new Promise(((resolveSubscribe) => { + let connectedResponse = new Promise((resolveConnected) => { + this.subscribeResponse = new Promise((resolveSubscribe) => { pubnub.addListener({ - status: function(statusEvent) { console.log('status', statusEvent.category) + status: function (statusEvent: StatusEvent) { + console.log('status', statusEvent.category); // Once the SDK fires this event - if (statusEvent.category === "PNConnectedCategory") { + if (statusEvent.category === 'PNConnectedCategory') { resolveConnected(); } }, - message: (m) => { + message: (m: MessageEvent) => { // remember the message received to compare and then resolve the promise this.message = m.message; resolveSubscribe(); - } + }, }); - })); - })); + }); + }); - pubnub.subscribe({ channels: [ this.channel ] }); + pubnub.subscribe({ channels: [this.channel] }); // return the promise so the next cucumber step waits for the sdk to return connected status return connectedResponse; }); -When('I publish the message {string} to channel {string}', async function(message, channel) { +When('I publish the message {string} to channel {string}', async function (message, channel) { // ensure the channel we subscribed to is the same we publish to expect(channel).to.equal(this.channel); // returning the promise so the next cucumber step will wait for the publish to complete return this.getPubnub().publish({ message: message, - channel: channel + channel: channel, }); }); -Then('I receive the message in my subscribe response', async function() { +Then('I receive the message in my subscribe response', async function () { // wait for the message to be received by the subscription and then // check the expected message matches the message received await this.subscribeResponse; diff --git a/test/old_contract/tsconfig.json b/test/old_contract/tsconfig.json new file mode 100644 index 000000000..d5da97333 --- /dev/null +++ b/test/old_contract/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "@tsconfig/node12/tsconfig.json", + "compilerOptions": { + "preserveConstEnums": true, + "noImplicitAny": false + }, + "include": ["**/*", "../contract/shared/enums.ts"], + "exclude": ["node_modules"] +} diff --git a/test/contract/utils.ts b/test/old_contract/utils.ts similarity index 79% rename from test/contract/utils.ts rename to test/old_contract/utils.ts index 2337b4d8e..f0386f635 100644 --- a/test/contract/utils.ts +++ b/test/old_contract/utils.ts @@ -1,6 +1,6 @@ import fs from 'fs'; -export function loadFixtureFile(persona) { +export function loadFixtureFile(persona: string) { const fileData = fs.readFileSync( `${process.cwd()}/dist/contract/contract/features/data/${persona.toLowerCase()}.json`, 'utf8', diff --git a/test/contract/world.ts b/test/old_contract/world.ts similarity index 54% rename from test/contract/world.ts rename to test/old_contract/world.ts index 08e8bd1c3..3ef2e3fa8 100644 --- a/test/contract/world.ts +++ b/test/old_contract/world.ts @@ -1,14 +1,10 @@ -import { - setWorldConstructor, - setDefaultTimeout, - World -} from '@cucumber/cucumber'; +import { setWorldConstructor, setDefaultTimeout, World } from '@cucumber/cucumber'; import PubNub from '../../lib/node/index.js'; import { loadFixtureFile } from './utils'; import * as http from 'http'; interface State { - pubnub: PubNub; + pubnub?: any; } const state: State = { @@ -16,12 +12,12 @@ const state: State = { }; setDefaultTimeout(20 * 1000); -class PubnubWorld extends World{ +class PubnubWorld extends World { settings = { checkContractExpectations: true, contractServer: 'localhost:8090', }; - fileFixtures = {}; + fileFixtures: Record = {}; fixtures = { // bronze config // defaultConfig: { @@ -36,27 +32,30 @@ class PubnubWorld extends World{ ssl: false, suppressLeaveEvents: true, logVerbosity: false, - uuid: 'myUUID' + uuid: 'myUUID', }, demoKeyset: { - publishKey : 'demo', - subscribeKey : 'demo', + publishKey: 'demo', + subscribeKey: 'demo', }, accessManagerKeyset: { - publishKey : process.env.PUBLISH_KEY_ACCESS || 'pub-key', - subscribeKey : process.env.SUBSCRIBE_KEY_ACCESS || 'sub-key', - secretKey: process.env.SECRET_KEY_ACCESS || 'secret-key' + publishKey: process.env.PUBLISH_KEY_ACCESS || 'pub-key', + subscribeKey: process.env.SUBSCRIBE_KEY_ACCESS || 'sub-key', + secretKey: process.env.SECRET_KEY_ACCESS || 'secret-key', }, accessManagerWithoutSecretKeyKeyset: { - publishKey : process.env.PUBLISH_KEY_ACCESS || 'pub-key', - subscribeKey : process.env.SUBSCRIBE_KEY_ACCESS || 'sub-key', + publishKey: process.env.PUBLISH_KEY_ACCESS || 'pub-key', + subscribeKey: process.env.SUBSCRIBE_KEY_ACCESS || 'sub-key', }, - tokenWithKnownAuthorizedUUID: 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc', - tokenWithUUIDResourcePermissions: 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc', - tokenWithUUIDPatternPermissions: 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc', + tokenWithKnownAuthorizedUUID: + 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc', + tokenWithUUIDResourcePermissions: + 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc', + tokenWithUUIDPatternPermissions: + 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc', }; - constructor(options) { + constructor(options: any) { super(options); } @@ -70,7 +69,7 @@ class PubnubWorld extends World{ // initialize instance of pubnub if config is passed // otherwise assume it is already initialied this.stopPubnub(); - state.pubnub = new PubNub(Object.assign({}, this.fixtures.defaultConfig, config)); + state.pubnub = new (PubNub as any)(Object.assign({}, this.fixtures.defaultConfig, config)) as any; } return state.pubnub; @@ -79,39 +78,36 @@ class PubnubWorld extends World{ async checkContract() { return new Promise((resolve) => { http.get(`http://${this.settings.contractServer}/expect`, (response) => { - let data: any = ''; - + response.on('data', (chunk) => { data += chunk; }); - + response.on('end', () => { let result; - + try { result = JSON.parse(data); } catch (e) { - console.log("error fetching expect results", e); + console.log('error fetching expect results', e); console.log(data); } resolve(result); }); - }); }); } /** * Disconnect pubnub subscribe loop - * + * * TODO: fix JS SDK so that we can choose when to end the loop explicitly * or atleast get a promise to tell us when it is complete. */ - async cleanup(delayInMilliseconds) { - + async cleanup(delayInMilliseconds: number) { if (!delayInMilliseconds) { - this.getPubnub().unsubscribeAll(); + this.getPubnub()?.unsubscribeAll(); } else { return new Promise((resolve) => { // allow a specified delay for subscribe loop before disconnecting @@ -127,7 +123,7 @@ class PubnubWorld extends World{ return this.cleanup(300); } - getFixture(name) { + getFixture(name: string) { if (!this.fileFixtures[name]) { const persona = loadFixtureFile(name); this.fileFixtures[name] = persona; From d1fad58b694dc10c0c1aceeff1269c469d12a14f Mon Sep 17 00:00:00 2001 From: Artur Wojciechowski Date: Wed, 30 Nov 2022 16:56:51 +0100 Subject: [PATCH 02/63] feat: add more steps --- .eslintrc.js | 1 + test/contract/definitions/auth.ts | 31 +++ test/contract/definitions/grant.ts | 37 +-- test/contract/shared/fixtures.ts | 2 + test/contract/shared/helpers.ts | 5 + test/contract/tsconfig.json | 3 +- test/old_contract/steps/access/grant_token.ts | 224 ------------------ 7 files changed, 63 insertions(+), 240 deletions(-) create mode 100644 test/contract/definitions/auth.ts create mode 100644 test/contract/shared/helpers.ts delete mode 100644 test/old_contract/steps/access/grant_token.ts diff --git a/.eslintrc.js b/.eslintrc.js index e2d59ccff..a4142bf28 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,5 +17,6 @@ module.exports = { 'class-methods-use-this': 0, 'no-prototype-builtins': 1, 'prefer-destructuring': 0, + 'no-unused-vars': 0, }, }; diff --git a/test/contract/definitions/auth.ts b/test/contract/definitions/auth.ts new file mode 100644 index 000000000..a91dd2731 --- /dev/null +++ b/test/contract/definitions/auth.ts @@ -0,0 +1,31 @@ +import { binding, given, then, when } from 'cucumber-tsflow'; +import { expect } from 'chai'; + +import { AccessManagerKeyset } from '../shared/keysets'; +import { PubNub, PubNubManager } from '../shared/pubnub'; +import { + tokenWithKnownAuthorizedUUID, + tokenWithUUIDPatternPermissions, + tokenWithUUIDResourcePermissions, +} from '../shared/fixtures'; +import { ResourceType, AccessPermission } from '../shared/enums'; + +import { ParsedGrantToken } from 'pubnub'; +import { exists } from '../shared/helpers'; + +@binding([PubNubManager, AccessManagerKeyset]) +class AuthSteps { + private pubnub?: PubNub; + + private token?: string; + + constructor(private manager: PubNubManager, private keyset: AccessManagerKeyset) {} + + @when('I publish a message using that auth token with channel {string}') + public publishMessage() { + exists(this.token); + exists(this.pubnub); + } +} + +export = AuthSteps; diff --git a/test/contract/definitions/grant.ts b/test/contract/definitions/grant.ts index 49053f162..358284b24 100644 --- a/test/contract/definitions/grant.ts +++ b/test/contract/definitions/grant.ts @@ -3,10 +3,15 @@ import { expect } from 'chai'; import { AccessManagerKeyset } from '../shared/keysets'; import { PubNub, PubNubManager } from '../shared/pubnub'; -import { tokenWithUUIDPatternPermissions } from '../shared/fixtures'; +import { + tokenWithKnownAuthorizedUUID, + tokenWithUUIDPatternPermissions, + tokenWithUUIDResourcePermissions, +} from '../shared/fixtures'; import { ResourceType, AccessPermission } from '../shared/enums'; import { ParsedGrantToken } from 'pubnub'; +import { exists } from '../shared/helpers'; @binding([PubNubManager, AccessManagerKeyset]) class GrantTokenSteps { @@ -22,13 +27,15 @@ class GrantTokenSteps { this.pubnub = this.manager.getInstance(this.keyset); } - // Given('I have a known token containing an authorized UUID', function () { - // this.token = this.fixtures.tokenWithKnownAuthorizedUUID; - // }); + @given('I have a known token containing an authorized UUID') + public useTokenWithKnownAuthorizedUUID() { + this.token = tokenWithKnownAuthorizedUUID; + } - // Given('I have a known token containing UUID resource permissions', function () { - // this.token = this.fixtures.tokenWithUUIDResourcePermissions; - // }); + @given('I have a known token containing UUID resource permissions') + public useTokenWithUUIDResourcePermissions() { + this.token = tokenWithUUIDResourcePermissions; + } @given('I have a known token containing UUID pattern Permissions') public useTokenWithUUIDPatternPermissions() { @@ -37,10 +44,10 @@ class GrantTokenSteps { @when('I parse the token') public parseToken() { - expect(this.token).to.exist; - expect(this.pubnub).to.exist; + exists(this.token); + exists(this.pubnub); - this.parsedToken = this.pubnub!.parseToken(this.token!); + this.parsedToken = this.pubnub.parseToken(this.token); expect(this.parsedToken).to.not.be.undefined; } @@ -53,16 +60,16 @@ class GrantTokenSteps { this.resourceName = name; this.resourceType = type; - expect(this.parsedToken?.patterns?.[type]).to.exist; - expect(this.parsedToken?.patterns?.[type]?.[name]).to.exist; + exists(this.parsedToken?.patterns?.[type]); + exists(this.parsedToken?.patterns?.[type]?.[name]); } @then('token pattern permission {access_permission}') public hasAccessPermission(permission: AccessPermission) { - expect(this.resourceType).to.exist; - expect(this.resourceName).to.exist; + exists(this.resourceType); + exists(this.resourceName); - expect(this.parsedToken?.patterns?.[this.resourceType!]?.[this.resourceName!]?.[permission]).to.be.true; + expect(this.parsedToken?.patterns?.[this.resourceType]?.[this.resourceName]?.[permission]).to.be.true; } } diff --git a/test/contract/shared/fixtures.ts b/test/contract/shared/fixtures.ts index a52ce325c..c6b106613 100644 --- a/test/contract/shared/fixtures.ts +++ b/test/contract/shared/fixtures.ts @@ -1,3 +1,5 @@ +/* eslint-disable max-len */ + export const tokenWithKnownAuthorizedUUID = 'qEF2AkF0GmEI03xDdHRsGDxDcmVzpURjaGFuoWljaGFubmVsLTEY70NncnChb2NoYW5uZWxfZ3JvdXAtMQVDdXNyoENzcGOgRHV1aWShZnV1aWQtMRhoQ3BhdKVEY2hhbqFtXmNoYW5uZWwtXFMqJBjvQ2dycKF0XjpjaGFubmVsX2dyb3VwLVxTKiQFQ3VzcqBDc3BjoER1dWlkoWpedXVpZC1cUyokGGhEbWV0YaBEdXVpZHR0ZXN0LWF1dGhvcml6ZWQtdXVpZENzaWdYIPpU-vCe9rkpYs87YUrFNWkyNq8CVvmKwEjVinnDrJJc'; diff --git a/test/contract/shared/helpers.ts b/test/contract/shared/helpers.ts new file mode 100644 index 000000000..39ed0a7f3 --- /dev/null +++ b/test/contract/shared/helpers.ts @@ -0,0 +1,5 @@ +import { expect } from 'chai'; + +export function exists(value: T | undefined): asserts value { + expect(value).to.exist; +} diff --git a/test/contract/tsconfig.json b/test/contract/tsconfig.json index 285ad6100..cb5e89f26 100644 --- a/test/contract/tsconfig.json +++ b/test/contract/tsconfig.json @@ -6,6 +6,7 @@ "experimentalDecorators": true, "target": "es5", "sourceMap": true, - "esModuleInterop": true + "esModuleInterop": true, + "strict": true } } diff --git a/test/old_contract/steps/access/grant_token.ts b/test/old_contract/steps/access/grant_token.ts deleted file mode 100644 index 83a780bc5..000000000 --- a/test/old_contract/steps/access/grant_token.ts +++ /dev/null @@ -1,224 +0,0 @@ -import { Given, When, Then, Before, After } from '@cucumber/cucumber'; -import { expect } from 'chai'; -import { AccessPermission, ResourceType } from '../../../contract/shared/enums.js'; - -// Before({ tags: '@contract=grantAllPermissions' }, function () { -// this.grantPayload = {}; -// }); - -Before(function () { - this.grantPayload = {}; -}); - -Given('I have a keyset with access manager enabled', function () { - console.log(this); - this.keyset = this.fixtures.accessManagerKeyset; -}); - -Given('the authorized UUID {string}', function (uuid: string) { - this.grantPayload.authorized_uuid = uuid; -}); - -Given('the TTL {int}', function (ttl: number) { - this.grantPayload.ttl = ttl; -}); - -Given( - 'the {string} {resource_type} resource access permissions', - function (resourceName: string, resourceType: ResourceType) { - this.resourceName = resourceName; - this.resourceType = resourceType; - - this.grantPayload.resources = this.grantPayload.resources || {}; - this.grantPayload.resources[this.resourceType] = this.grantPayload.resources[this.resourceType] || {}; - - this.grantPayload.resources[this.resourceType][this.resourceName] = {}; - }, -); - -Given( - 'the {string} {resource_type} pattern access permissions', - function (resourceName: string, resourceType: ResourceType) { - this.resourceName = resourceName; - this.resourceType = resourceType; - - this.grantPayload.patterns = this.grantPayload.patterns || {}; - this.grantPayload.patterns[this.resourceType] = this.grantPayload.patterns[this.resourceType] || {}; - - this.grantPayload.patterns[this.resourceType][this.resourceName] = {}; - }, -); - -Given('grant resource permission {access_permission}', function (accessPermission: AccessPermission) { - this.grantPayload.resources[this.resourceType][this.resourceName][accessPermission] = true; -}); - -Given('deny resource permission {access_permission}', function (accessPermission: AccessPermission) { - this.grantPayload.resources[this.resourceType][this.resourceName][accessPermission] = false; -}); - -Given('grant pattern permission {access_permission}', function (accessPermission: AccessPermission) { - this.grantPayload.patterns[this.resourceType][this.resourceName][accessPermission] = true; -}); - -Given('deny pattern permission {access_permission}', function (accessPermission: AccessPermission) { - this.grantPayload.patterns[this.resourceType][this.resourceName][accessPermission] = false; -}); - -When('I grant a token specifying those permissions', async function () { - const pubnub = await this.getPubnub({ - publishKey: this.keyset.publishKey, - subscribeKey: this.keyset.subscribeKey, - secretKey: this.keyset.secretKey, - }); - - this.token = await pubnub.grantToken(this.grantPayload); - expect(this.token).not.to.be.empty; - // console.log('token', this.token); - this.parsedToken = pubnub.parseToken(this.token); - expect(this.parsedToken).to.exist; - // console.log('parsed token', JSON.stringify(this.parsedToken, null, 2)); -}); - -When('I attempt to grant a token specifying those permissions', async function () { - const pubnub = await this.getPubnub({ - publishKey: this.keyset.publishKey, - subscribeKey: this.keyset.subscribeKey, - secretKey: this.keyset.secretKey, - }); - - try { - this.token = await pubnub.grantToken(this.grantPayload); - // console.log('not expected token', this.token) - } catch (e: any) { - // console.log('expected error', e) - this.expectedError = e?.status?.errorData; - } - expect(this.expectedError).not.to.be.undefined; -}); - -Then('the token contains the TTL {int}', function (ttl: number) { - expect(this.parsedToken.ttl).to.equal(ttl); -}); - -Then('the token contains the authorized UUID {string}', function (uuid: string) { - expect(this.parsedToken.authorized_uuid).to.equal(uuid); -}); - -Then( - 'the token has {string} {resource_type} resource access permissions', - function (resourceName: string, resourceType: ResourceType) { - this.resourceName = resourceName; - this.resourceType = resourceType; - expect(this.parsedToken.resources[this.resourceType]).to.exist; - expect(this.parsedToken.resources[this.resourceType][this.resourceName]).to.exist; - }, -); - -Then( - 'the token has {string} {resource_type} pattern access permissions', - function (resourceName: string, resourceType: ResourceType) { - this.resourceName = resourceName; - this.resourceType = resourceType; - - expect(this.parsedToken.patterns[this.resourceType]).to.exist; - expect(this.parsedToken.patterns[this.resourceType][this.resourceName]).to.exist; - }, -); - -Then('token resource permission {access_permission}', function (accessPermission: AccessPermission) { - expect(this.parsedToken.resources[this.resourceType][this.resourceName][accessPermission]).to.be.true; -}); - -Then('token pattern permission {access_permission}', function (accessPermission: AccessPermission) { - expect(this.parsedToken.patterns[this.resourceType][this.resourceName][accessPermission]).to.be.true; -}); - -Then('the token does not contain an authorized uuid', function () { - expect(this.parsedToken.uuid).to.be.undefined; -}); - -Then('an error is returned', function () { - expect(this.expectedError.status).to.be.a('number'); - - expect(this.expectedError.error).to.be.an('object'); - expect(this.expectedError.error).to.have.keys(['message', 'source', 'details']); - - expect(this.expectedError.error.message).to.be.a('string'); - - expect(this.expectedError.error.source).to.be.a('string'); - - expect(this.expectedError.error.details).to.be.an('array'); - expect(this.expectedError.error.details).to.have.lengthOf.at.least(1); - - let details = this.expectedError.error.details[0]; - - expect(details).to.be.an('object'); - expect(details).to.have.keys(['message', 'location', 'locationType']); - - expect(details.message).to.be.a('string'); - expect(details.location).to.be.a('string'); - expect(details.locationType).to.be.a('string'); -}); - -Then('the error status code is {int}', function (statusCode: number) { - expect(this.expectedError.status).to.equal(statusCode); -}); - -Then('the error message is {string}', function (errorMessage) { - expect(this.expectedError.error.message).to.equal(errorMessage); -}); - -Then('the error service is {string}', function (errorService) { - expect(this.expectedError.service).to.equal(errorService); -}); - -Then('the error source is {string}', function (errorSource: string) { - expect(this.expectedError.error.source).to.equal(errorSource); -}); - -Then('the error detail message is {string}', function (detailsMessage) { - let details = this.expectedError.error.details[0]; - expect(details.message).to.equal(detailsMessage); -}); - -Then('the error detail message is not empty', function () { - let details = this.expectedError.error.details[0]; - expect(details.message).to.not.to.be.empty; -}); - -Then('the error detail location is {string}', function (errorLocation: string) { - let details = this.expectedError.error.details[0]; - expect(details.location).to.equal(errorLocation); -}); - -Then('the error detail location type is {string}', function (errorLocationType: string) { - let details = this.expectedError.error.details[0]; - expect(details.locationType).to.equal(errorLocationType); -}); - -Given('I have a known token containing an authorized UUID', function () { - this.token = this.fixtures.tokenWithKnownAuthorizedUUID; -}); - -Given('I have a known token containing UUID resource permissions', function () { - this.token = this.fixtures.tokenWithUUIDResourcePermissions; -}); - -Given('I have a known token containing UUID pattern Permissions', function () { - this.token = this.fixtures.tokenWithUUIDPatternPermissions; -}); - -When('I parse the token', function () { - expect(this.token).not.to.be.empty; - let pubnub = this.getPubnub({ - publishKey: this.keyset.publishKey, - subscribeKey: this.keyset.subscribeKey, - }); - this.parsedToken = pubnub.parseToken(this.token); -}); - -Then('the parsed token output contains the authorized UUID {string}', function (uuid) { - expect(this.parsedToken).to.exist; - expect(this.parsedToken.authorized_uuid).to.equal(uuid); -}); From 11a5670d2d622711e5f7f82ffdfd7472915a847d Mon Sep 17 00:00:00 2001 From: Artur Wojciechowski Date: Fri, 12 May 2023 11:30:45 +0200 Subject: [PATCH 03/63] feat: current progress --- .eslintrc.js | 1 + cucumber.js | 1 + dist/web/pubnub.js | 78 +- dist/web/pubnub.min.js | 4 +- lib/core/pubnub-common.js | 38 +- lib/event-engine/core/dispatcher.js | 44 + lib/event-engine/core/handler.js | 5 +- lib/event-engine/dispatcher.js | 17 +- lib/event-engine/effects.js | 5 +- lib/event-engine/events.js | 8 +- lib/event-engine/index.js | 7 +- lib/event-engine/states/handshake_failure.js | 2 + .../states/handshake_reconnecting.js | 10 +- lib/event-engine/states/receiving.js | 1 + package-lock.json | 1508 +++++++++++------ package.json | 8 +- src/core/pubnub-common.js | 16 +- src/event-engine/core/dispatcher.ts | 7 + src/event-engine/core/handler.ts | 5 +- src/event-engine/dispatcher.ts | 18 +- src/event-engine/effects.ts | 14 +- src/event-engine/events.ts | 8 +- src/event-engine/index.ts | 10 +- src/event-engine/states/handshake_failure.ts | 4 +- .../states/handshake_reconnecting.ts | 31 +- src/event-engine/states/receiving.ts | 3 +- test/contract/definitions/event-engine.ts | 118 ++ test/contract/definitions/grant.ts | 125 +- test/contract/setup.js | 12 +- test/contract/shared/enums.ts | 2 +- test/contract/shared/hooks.ts | 52 + test/contract/shared/keysets.ts | 9 +- test/contract/shared/pubnub.ts | 1 + test/contract/tsconfig.json | 7 +- 34 files changed, 1567 insertions(+), 612 deletions(-) create mode 100644 test/contract/definitions/event-engine.ts create mode 100644 test/contract/shared/hooks.ts diff --git a/.eslintrc.js b/.eslintrc.js index a4142bf28..126ec3995 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -18,5 +18,6 @@ module.exports = { 'no-prototype-builtins': 1, 'prefer-destructuring': 0, 'no-unused-vars': 0, + '@typescript-eslint/no-unused-vars': 0, }, }; diff --git a/cucumber.js b/cucumber.js index 1bb853c25..ff60e6702 100644 --- a/cucumber.js +++ b/cucumber.js @@ -3,6 +3,7 @@ module.exports = { 'test/specs/features/**/*.feature', '--require test/contract/setup.js', '--require test/contract/definitions/**/*.ts', + '--require test/contract/shared/**/*.ts', '--format summary', '--format progress-bar', // '--format @cucumber/pretty-formatter', diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index 19ac5dfd8..f9880d2dc 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -6891,6 +6891,23 @@ } instance.start(); }; + Dispatcher.prototype.dispose = function () { + var e_1, _a; + try { + for (var _b = __values(this.instances.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { + var _d = __read(_c.value, 2), key = _d[0], instance = _d[1]; + instance.cancel(); + this.instances.delete(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + }; return Dispatcher; }()); @@ -6986,7 +7003,9 @@ return _this; } AsyncHandler.prototype.start = function () { - this.asyncFunction(this.payload, this.abortSignal, this.dependencies); + this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch(function () { + // swallow the error + }); }; AsyncHandler.prototype.cancel = function () { this.abortSignal.abort(); @@ -7005,6 +7024,7 @@ }); }); var receiveEvents = createManagedEffect('RECEIVE_EVENTS', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); var emitEvents = createEffect('EMIT_EVENTS', function (events) { return events; }); + var emitStatus = createEffect('EMIT_STATUS', function (status) { return status; }); var reconnect$1 = createManagedEffect('RECONNECT', function (context) { return context; }); var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); @@ -7116,16 +7136,25 @@ }); })); _this.on(emitEvents.type, asyncHandler(function (payload, abortSignal, _a) { - _a.receiveEvents; + var emitEvents = _a.emitEvents; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { if (payload.length > 0) { - console.log(payload); + emitEvents(payload); } return [2 /*return*/]; }); }); })); + _this.on(emitStatus.type, asyncHandler(function (payload, abortSignal, _a) { + var emitStatus = _a.emitStatus; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + emitStatus(payload); + return [2 /*return*/]; + }); + }); + })); _this.on(reconnect$1.type, asyncHandler(function (payload, abortSignal, _a) { var receiveEvents = _a.receiveEvents, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; return __awaiter(_this, void 0, void 0, function () { @@ -7286,6 +7315,7 @@ var ReceivingState = new State('RECEIVING'); ReceivingState.onEnter(function (context) { return receiveEvents(context.channels, context.groups, context.cursor); }); + ReceivingState.onEnter(function (context) { return emitStatus({ category: 'PNConnectedCategory' }); }); ReceivingState.onExit(function () { return receiveEvents.cancel; }); ReceivingState.on(receivingSuccess.type, function (context, event) { return ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [emitEvents(event.payload.events)]); @@ -7310,17 +7340,17 @@ var HandshakeReconnectingState = new State('HANDSHAKE_RECONNECTING'); HandshakeReconnectingState.onEnter(function (context) { return handshakeReconnect(context); }); HandshakeReconnectingState.onExit(function () { return reconnect$1.cancel; }); - HandshakeReconnectingState.on(reconnectingSuccess.type, function (context, event) { + HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, function (context, event) { return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor, - }, [emitEvents(event.payload.events)]); + }); }); - HandshakeReconnectingState.on(reconnectingFailure.type, function (context, event) { + HandshakeReconnectingState.on(handshakingReconnectingFailure.type, function (context, event) { return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); }); - HandshakeReconnectingState.on(reconnectingGiveup.type, function (context) { + HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, function (context) { return HandshakeFailureState.with({ groups: context.groups, channels: context.channels, @@ -7372,7 +7402,7 @@ this.channels = []; this.groups = []; this.dispatcher = new EventEngineDispatcher(this.engine, dependencies); - this.engine.subscribe(function (change) { + this._unsubscribeEngine = this.engine.subscribe(function (change) { if (change.type === 'invocationDispatched') { _this.dispatcher.dispatch(change.invocation); } @@ -7409,6 +7439,11 @@ EventEngine.prototype.disconnect = function () { this.engine.transition(disconnect()); }; + EventEngine.prototype.dispose = function () { + this.disconnect(); + this._unsubscribeEngine(); + this.dispatcher.dispose(); + }; return EventEngine; }()); @@ -7454,7 +7489,32 @@ this.handshake = endpointCreator.bind(this, modules, endpoint$1); this.receiveMessages = endpointCreator.bind(this, modules, endpoint); if (config.enableSubscribeBeta === true) { - var eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages }); + var eventEngine = new EventEngine({ + handshake: this.handshake, + receiveEvents: this.receiveMessages, + getRetryDelay: function (attempts) { return attempts * 25; }, + delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, + shouldRetry: function (error, attempts) { return attempts < 3; }, + emitEvents: function (events) { + var e_1, _a; + try { + for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { + var event_1 = events_1_1.value; + listenerManager.announceMessage(event_1); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1); + } + finally { if (e_1) throw e_1.error; } + } + }, + emitStatus: function (status) { + listenerManager.announceStatus(status); + }, + }); this.subscribe = eventEngine.subscribe.bind(eventEngine); this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); this.eventEngine = eventEngine; diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 289acf653..230f704eb 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var b=function e(){var i,h,b=l(),v=b>>5,m=31&b;if(7===v)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(v<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(v))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var N;if(h<0)for(N=[];!f();)N.push(e());else for(N=new Array(h),i=0;i0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var v=function e(){var i,h,v=l(),b=v>>5,m=31&v;if(7===b)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(b<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(b))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var N;if(h<0)for(N=[];!f();)N.push(e());else for(N=new Array(h),i=0;i=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.2"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var b,v,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),v=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=v.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],b=e[o+9],v=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],N=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,N,k,a,12,c[1]),k=t(k,T,w,N,l,17,c[2]),N=t(N,k,T,w,p,22,c[3]);w=t(w,N,k,T,h,7,c[4]),T=t(T,w,N,k,f,12,c[5]),k=t(k,T,w,N,d,17,c[6]),N=t(N,k,T,w,g,22,c[7]),w=t(w,N,k,T,y,7,c[8]),T=t(T,w,N,k,b,12,c[9]),k=t(k,T,w,N,v,17,c[10]),N=t(N,k,T,w,m,22,c[11]),w=t(w,N,k,T,_,7,c[12]),T=t(T,w,N,k,O,12,c[13]),k=t(k,T,w,N,P,17,c[14]),w=n(w,N=t(N,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,N,k,d,9,c[17]),k=n(k,T,w,N,m,14,c[18]),N=n(N,k,T,w,u,20,c[19]),w=n(w,N,k,T,f,5,c[20]),T=n(T,w,N,k,v,9,c[21]),k=n(k,T,w,N,S,14,c[22]),N=n(N,k,T,w,h,20,c[23]),w=n(w,N,k,T,b,5,c[24]),T=n(T,w,N,k,P,9,c[25]),k=n(k,T,w,N,p,14,c[26]),N=n(N,k,T,w,y,20,c[27]),w=n(w,N,k,T,O,5,c[28]),T=n(T,w,N,k,l,9,c[29]),k=n(k,T,w,N,g,14,c[30]),w=r(w,N=n(N,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,N,k,y,11,c[33]),k=r(k,T,w,N,m,16,c[34]),N=r(N,k,T,w,P,23,c[35]),w=r(w,N,k,T,a,4,c[36]),T=r(T,w,N,k,h,11,c[37]),k=r(k,T,w,N,g,16,c[38]),N=r(N,k,T,w,v,23,c[39]),w=r(w,N,k,T,O,4,c[40]),T=r(T,w,N,k,u,11,c[41]),k=r(k,T,w,N,p,16,c[42]),N=r(N,k,T,w,d,23,c[43]),w=r(w,N,k,T,b,4,c[44]),T=r(T,w,N,k,_,11,c[45]),k=r(k,T,w,N,S,16,c[46]),w=i(w,N=r(N,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,N,k,g,10,c[49]),k=i(k,T,w,N,P,15,c[50]),N=i(N,k,T,w,f,21,c[51]),w=i(w,N,k,T,_,6,c[52]),T=i(T,w,N,k,p,10,c[53]),k=i(k,T,w,N,v,15,c[54]),N=i(N,k,T,w,a,21,c[55]),w=i(w,N,k,T,y,6,c[56]),T=i(T,w,N,k,S,10,c[57]),k=i(k,T,w,N,d,15,c[58]),N=i(N,k,T,w,O,21,c[59]),w=i(w,N,k,T,h,6,c[60]),T=i(T,w,N,k,m,10,c[61]),k=i(k,T,w,N,l,15,c[62]),N=i(N,k,T,w,b,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+N|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var b=(b=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&b^99;r[g]=b,i[b]=g;var v=f[g],m=f[v],_=f[m],O=257*f[b]^16843008*b;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*v^16843008*g,c[b]=O<<24|O>>>8,l[b]=O<<16|O>>>16,p[b]=O<<8|O>>>24,h[b]=O,g?(g=v^f[f[f[_^v]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],b=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=b}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],b=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=b,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function C(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function E(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return E(e).map((function(t){return"".concat(t,"=").concat(C(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:C},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},j=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new N({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),R={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==R.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==R.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case R.PNPublishOperation:t="pub";break;case R.PNSignalOperation:t="sig";break;case R.PNHistoryOperation:case R.PNFetchMessagesOperation:case R.PNDeleteMessagesOperation:case R.PNMessageCounts:t="hist";break;case R.PNUnsubscribeOperation:case R.PNWhereNowOperation:case R.PNHereNowOperation:case R.PNHeartbeatOperation:case R.PNSetStateOperation:case R.PNGetStateOperation:t="pres";break;case R.PNAddChannelsToGroupOperation:case R.PNRemoveChannelsFromGroupOperation:case R.PNChannelGroupsOperation:case R.PNRemoveGroupOperation:case R.PNChannelsForGroupOperation:t="cg";break;case R.PNPushNotificationEnabledChannelsOperation:case R.PNRemoveAllPushNotificationsOperation:t="push";break;case R.PNCreateUserOperation:case R.PNUpdateUserOperation:case R.PNDeleteUserOperation:case R.PNGetUserOperation:case R.PNGetUsersOperation:case R.PNCreateSpaceOperation:case R.PNUpdateSpaceOperation:case R.PNDeleteSpaceOperation:case R.PNGetSpaceOperation:case R.PNGetSpacesOperation:case R.PNGetMembersOperation:case R.PNUpdateMembersOperation:case R.PNGetMembershipsOperation:case R.PNUpdateMembershipsOperation:t="obj";break;case R.PNAddMessageActionOperation:case R.PNRemoveMessageActionOperation:case R.PNGetMessageActionsOperation:t="msga";break;case R.PNAccessManagerGrant:case R.PNAccessManagerAudit:t="pam";break;case R.PNAccessManagerGrantToken:case R.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function W(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return R.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return R.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return R.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return R.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return R.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return R.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return R.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return R.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,b,v,m,_,O,P,S,w,T,k,N,C,E,A,M,j,R,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,b=i.url,v=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=v,e.mimeType&&(P=v.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[b,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(C=(N=l).POSTFILE,E=[b,P],[4,e.toFile()]):[3,10];case 8:return[4,C.apply(N,E.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,j=[b,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,j.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(R=l).POSTFILE,x=[b,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(R,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},ve={getOperation:function(){return R.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return R.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return R.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return R.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return R.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return R.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return R.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return R.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return R.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return R.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ee={getOperation:function(){return R.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return R.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return R.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var je=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var Re=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,b=t.join,v=void 0!==b&&b,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=v?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return R.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return R.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return R.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return R.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return R.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return R.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return R.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return R.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var We=Object.freeze({__proto__:null,getOperation:function(){return R.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Xe={getOperation:function(){return R.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return R.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var b=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:b,fromContext:v,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&console.log(e),[2]}))}))}))),r.on(ft.type,ct((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Ct())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Nt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(dt.type,ct((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r.metadata))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(gt.type,(function(e,t){return Mt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(bt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("HANDSHAKE_FAILURE");jt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),jt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Rt=new Ye("STOPPED");Rt.on(gt.type,(function(e,t){return Rt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(bt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Et.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ft(e)})),xt.onExit((function(){return ft.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),xt.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Ct.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason})})),xt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return pt.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[ht(t.payload.events)])})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),Dt.on(Nt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Ct.type,(function(e){return jt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return lt(e.channels,e.groups)})),Gt.onExit((function(){return lt.cancel})),Gt.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(vt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(gt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(gt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(bt())},e.prototype.disconnect=function(){this.engine.transition(yt())},e}(),Lt=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new g({setup:e});this._config=o;var s=new T({config:o}),c=e.cryptography;r.init(o);var l=new L(o,i);this._tokenManager=l;var p=new U({maximumSamplesCount:6e4});this._telemetryManager=p;var h={config:o,networking:r,crypto:s,cryptography:c,tokenManager:l,telemetryManager:p,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return c.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return c.decryptFile(e,n,t.File)};var f=W.bind(this,h,Je),d=W.bind(this,h,ie),y=W.bind(this,h,se),b=W.bind(this,h,ue),v=W.bind(this,h,We),m=new F;if(this._listenerManager=m,this.iAmHere=W.bind(this,h,se),this.iAmAway=W.bind(this,h,ie),this.setPresenceState=W.bind(this,h,ue),this.handshake=W.bind(this,h,Xe),this.receiveMessages=W.bind(this,h,$e),!0===o.enableSubscribeBeta){var _=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages});this.subscribe=_.subscribe.bind(_),this.unsubscribe=_.unsubscribe.bind(_),this.eventEngine=_}else{var O=new j({timeEndpoint:f,leaveEndpoint:d,heartbeatEndpoint:y,setStateEndpoint:b,subscribeEndpoint:v,crypto:h.crypto,config:h.config,listenerManager:m,getFileUrl:function(e){return be(h,e)}});this.subscribe=O.adaptSubscribeChange.bind(O),this.unsubscribe=O.adaptUnsubscribeChange.bind(O),this.disconnect=O.disconnect.bind(O),this.reconnect=O.reconnect.bind(O),this.unsubscribeAll=O.unsubscribeAll.bind(O),this.getSubscribedChannels=O.getSubscribedChannels.bind(O),this.getSubscribedChannelGroups=O.getSubscribedChannelGroups.bind(O),this.setState=O.adaptStateChange.bind(O),this.presence=O.adaptPresenceChange.bind(O),this.destroy=function(e){O.unsubscribeAll(e),O.disconnect()}}this.addListener=m.addListener.bind(m),this.removeListener=m.removeListener.bind(m),this.removeAllListeners=m.removeAllListeners.bind(m),this.parseToken=l.parseToken.bind(l),this.setToken=l.setToken.bind(l),this.getToken=l.getToken.bind(l),this.channelGroups={listGroups:W.bind(this,h,Y),listChannels:W.bind(this,h,Z),addChannels:W.bind(this,h,X),removeChannels:W.bind(this,h,$),deleteGroup:W.bind(this,h,Q)},this.push={addChannels:W.bind(this,h,ee),removeChannels:W.bind(this,h,te),deleteDevice:W.bind(this,h,re),listChannels:W.bind(this,h,ne)},this.hereNow=W.bind(this,h,ce),this.whereNow=W.bind(this,h,oe),this.getState=W.bind(this,h,ae),this.grant=W.bind(this,h,Re),this.grantToken=W.bind(this,h,De),this.audit=W.bind(this,h,je),this.revokeToken=W.bind(this,h,Ge),this.publish=W.bind(this,h,Fe),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=W.bind(this,h,Le),this.history=W.bind(this,h,He),this.deleteMessages=W.bind(this,h,qe),this.messageCounts=W.bind(this,h,ze),this.fetchMessages=W.bind(this,h,Ve),this.addMessageAction=W.bind(this,h,le),this.removeMessageAction=W.bind(this,h,pe),this.getMessageActions=W.bind(this,h,he),this.listFiles=W.bind(this,h,fe);var P=W.bind(this,h,de);this.publishFile=W.bind(this,h,ge),this.sendFile=ye({generateUploadUrl:P,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return be(h,e)},this.downloadFile=W.bind(this,h,ve),this.deleteFile=W.bind(this,h,me),this.objects={getAllUUIDMetadata:W.bind(this,h,_e),getUUIDMetadata:W.bind(this,h,Oe),setUUIDMetadata:W.bind(this,h,Pe),removeUUIDMetadata:W.bind(this,h,Se),getAllChannelMetadata:W.bind(this,h,we),getChannelMetadata:W.bind(this,h,Te),setChannelMetadata:W.bind(this,h,ke),removeChannelMetadata:W.bind(this,h,Ne),getChannelMembers:W.bind(this,h,Ce),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function Ht(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?Ht(s):s})),n}var qt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),zt={exports:{}},Vt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function rn(e,t,n,r){void 0===r&&(r=Yt());var i,o=on(e,"",0,[],void 0,0,r)||e;try{i=0===Qt.length?JSON.stringify(o,t,n):JSON.stringify(o,sn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==$t.length;){var s=$t.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function on(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(fn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===pn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=dn[u]:u<2048?s+=dn[192|u>>6]+dn[128|63&u]:u<55296||u>=57344?s+=dn[224|u>>12]+dn[128|u>>6&63]+dn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=dn[240|u>>18]+dn[128|u>>12&63]+dn[128|u>>6&63]+dn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(fn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(On(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},xn=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&An.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},In={formats:ln,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||En.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Mn(l)?[l]:l),An.call(r,c)?r[c]=En.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Dn(e){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dn(e)}var Gn=function(e){return null!==e&&"object"===Dn(e)};function Kn(e){return Kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kn(e)}var Fn=Gn,Ln=Bn;function Bn(e){if(e)return function(e){for(var t in Bn.prototype)Object.prototype.hasOwnProperty.call(Bn.prototype,t)&&(e[t]=Bn.prototype[t]);return e}(e)}Bn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Bn.prototype.parse=function(e){return this._parser=e,this},Bn.prototype.responseType=function(e){return this._responseType=e,this},Bn.prototype.serialize=function(e){return this._serializer=e,this},Bn.prototype.timeout=function(e){if(!e||"object"!==Kn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Bn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var Hn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),qn=new Set([408,413,429,500,502,503,504,521,522,524]);Bn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&qn.has(t.status))return!0;if(e){if(e.code&&Hn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Bn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Bn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Bn.prototype.catch=function(e){return this.then(void 0,e)},Bn.prototype.use=function(e){return e(this),this},Bn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Bn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Bn.prototype.get=function(e){return this._header[e.toLowerCase()]},Bn.prototype.getHeader=Bn.prototype.get,Bn.prototype.set=function(e,t){if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Bn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Bn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Bn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Bn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Bn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Bn.prototype.redirects=function(e){return this._maxRedirects=e,this},Bn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Bn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Bn.prototype.send=function(e){var t=Fn(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Fn(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Bn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Bn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Bn.prototype._appendQueryString=function(){console.warn("Unsupported")},Bn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Bn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var zn={};function Vn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},v.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=v,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(zt,zt.exports);var tr=zt.exports;function nr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function rr(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(nr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function ir(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=tr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function or(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function sr(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function ar(e,t,n,r){var i=tr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function ur(e,t,n,r){var i=tr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function cr(e,t,n){var r=tr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function lr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var pr,hr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=lr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=lr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),fr=(pr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),pr.supportsFile="undefined"!=typeof File,pr.supportsBlob="undefined"!=typeof Blob,pr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,pr.supportsBuffer=!1,pr.supportsStream=!1,pr.supportsString=!0,pr.supportsEncryptFile=!0,pr.supportsFileUri=!1,pr);function dr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var gr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Bt({del:cr,get:sr,post:ar,patch:ur,sendBeacon:dr,getfile:or,postfile:ir}),t.cbor=new qt((function(e){return Ht(p.decode(e))}),y),t.PubNubFile=fr,t.cryptography=new hr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Lt);return gr})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 i(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=i,r.VERSION=t,e.uuid=r,e.isUUID=i}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var f=h.exports,d=function(){return f.uuid?f.uuid():f()},g=function(){function e(e){var t,n,r,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(d()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.setCipherKey(i.cipherKey),this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableSubscribeBeta=null!==(r=i.enableSubscribeBeta)&&void 0!==r&&r,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e){return this.cipherKey=e,this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.2"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],k=s[1],T=s[2],N=s[3],u,7,c[0]),N=t(N,w,k,T,a,12,c[1]),T=t(T,N,w,k,l,17,c[2]),k=t(k,T,N,w,p,22,c[3]);w=t(w,k,T,N,h,7,c[4]),N=t(N,w,k,T,f,12,c[5]),T=t(T,N,w,k,d,17,c[6]),k=t(k,T,N,w,g,22,c[7]),w=t(w,k,T,N,y,7,c[8]),N=t(N,w,k,T,v,12,c[9]),T=t(T,N,w,k,b,17,c[10]),k=t(k,T,N,w,m,22,c[11]),w=t(w,k,T,N,_,7,c[12]),N=t(N,w,k,T,O,12,c[13]),T=t(T,N,w,k,P,17,c[14]),w=n(w,k=t(k,T,N,w,S,22,c[15]),T,N,a,5,c[16]),N=n(N,w,k,T,d,9,c[17]),T=n(T,N,w,k,m,14,c[18]),k=n(k,T,N,w,u,20,c[19]),w=n(w,k,T,N,f,5,c[20]),N=n(N,w,k,T,b,9,c[21]),T=n(T,N,w,k,S,14,c[22]),k=n(k,T,N,w,h,20,c[23]),w=n(w,k,T,N,v,5,c[24]),N=n(N,w,k,T,P,9,c[25]),T=n(T,N,w,k,p,14,c[26]),k=n(k,T,N,w,y,20,c[27]),w=n(w,k,T,N,O,5,c[28]),N=n(N,w,k,T,l,9,c[29]),T=n(T,N,w,k,g,14,c[30]),w=r(w,k=n(k,T,N,w,_,20,c[31]),T,N,f,4,c[32]),N=r(N,w,k,T,y,11,c[33]),T=r(T,N,w,k,m,16,c[34]),k=r(k,T,N,w,P,23,c[35]),w=r(w,k,T,N,a,4,c[36]),N=r(N,w,k,T,h,11,c[37]),T=r(T,N,w,k,g,16,c[38]),k=r(k,T,N,w,b,23,c[39]),w=r(w,k,T,N,O,4,c[40]),N=r(N,w,k,T,u,11,c[41]),T=r(T,N,w,k,p,16,c[42]),k=r(k,T,N,w,d,23,c[43]),w=r(w,k,T,N,v,4,c[44]),N=r(N,w,k,T,_,11,c[45]),T=r(T,N,w,k,S,16,c[46]),w=i(w,k=r(k,T,N,w,l,23,c[47]),T,N,u,6,c[48]),N=i(N,w,k,T,g,10,c[49]),T=i(T,N,w,k,P,15,c[50]),k=i(k,T,N,w,f,21,c[51]),w=i(w,k,T,N,_,6,c[52]),N=i(N,w,k,T,p,10,c[53]),T=i(T,N,w,k,b,15,c[54]),k=i(k,T,N,w,a,21,c[55]),w=i(w,k,T,N,y,6,c[56]),N=i(N,w,k,T,S,10,c[57]),T=i(T,N,w,k,d,15,c[58]),k=i(k,T,N,w,O,21,c[59]),w=i(w,k,T,N,h,6,c[60]),N=i(N,w,k,T,m,10,c[61]),T=i(T,N,w,k,l,15,c[62]),k=i(k,T,N,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+k|0,s[2]=s[2]+T|0,s[3]=s[3]+N|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function C(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function E(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A,M={signPamFromParams:function(e){return E(e).map((function(t){return"".concat(t,"=").concat(C(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:C},U={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},R=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new T({timeEndpoint:o}),this._dedupingManager=new k({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===U.PNTimeoutCategory?this._startSubscribeLoop():e.category===U.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:U.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===U.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=U.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=U.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(M.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}();!function(e){e.Time="PNTimeOperation",e.History="PNHistoryOperation",e.DeleteMessages="PNDeleteMessagesOperation",e.FetchMessages="PNFetchMessagesOperation",e.MessageCounts="PNMessageCountsOperation",e.Subscribe="PNSubscribeOperation",e.Unsubscribe="PNUnsubscribeOperation",e.Publish="PNPublishOperation",e.Signal="PNSignalOperation",e.AddMessageAction="PNAddActionOperation",e.RemoveMessageAction="PNRemoveMessageActionOperation",e.GetMessageActions="PNGetMessageActionsOperation",e.CreateUser="PNCreateUserOperation",e.UpdateUser="PNUpdateUserOperation",e.RemoveUser="PNRemoveUserOperation",e.FetchUser="PNFetchUserOperation",e.GetUsers="PNGetUsersOperation",e.CreateSpace="PNCreateSpaceOperation",e.UpdateSpace="PNUpdateSpaceOperation",e.RemoveSpace="PNRemoveSpaceOperation",e.FetchSpace="PNFetchSpaceOperation",e.GetSpaces="PNGetSpacesOperation",e.GetMembers="PNGetMembersOperation",e.UpdateMembers="PNUpdateMembersOperation",e.GetMemberships="PNGetMembershipsOperation",e.UpdateMemberships="PNUpdateMembershipsOperation",e.ListFiles="PNListFilesOperation",e.GenerateUploadUrl="PNGenerateUploadUrlOperation",e.PublishFile="PNPublishFileOperation",e.GetFileUrl="PNGetFileUrlOperation",e.DownloadFile="PNDownloadFileOperation",e.GetAllUUIDMetadata="PNGetAllUUIDMetadataOperation",e.GetUUIDMetadata="PNGetUUIDMetadataOperation",e.SetUUIDMetadata="PNSetUUIDMetadataOperation",e.RemoveUUIDMetadata="PNRemoveUUIDMetadataOperation",e.GetAllChannelMetadata="PNGetAllChannelMetadataOperation",e.GetChannelMetadata="PNGetChannelMetadataOperation",e.SetChannelMetadata="PNSetChannelMetadataOperation",e.RemoveChannelMetadata="PNRemoveChannelMetadataOperation",e.SetMembers="PNSetMembersOperation",e.SetMemberships="PNSetMembershipsOperation",e.PushNotificationEnabledChannels="PNPushNotificationEnabledChannelsOperation",e.RemoveAllPushNotifications="PNRemoveAllPushNotificationsOperation",e.WhereNow="PNWhereNowOperation",e.SetState="PNSetStateOperation",e.HereNow="PNHereNowOperation",e.GetState="PNGetStateOperation",e.Heartbeat="PNHeartbeatOperation",e.ChannelGroups="PNChannelGroupsOperation",e.RemoveGroup="PNRemoveGroupOperation",e.ChannelsForGroup="PNChannelsForGroupOperation",e.AddChannelsToGroup="PNAddChannelsToGroupOperation",e.RemoveChannelsFromGroup="PNRemoveChannelsFromGroupOperation",e.AccessManagerGrant="PNAccessManagerGrant",e.AccessManagerGrantToken="PNAccessManagerGrantToken",e.AccessManagerAudit="PNAccessManagerAudit",e.AccessManagerRevokeToken="PNAccessManagerRevokeToken",e.Handshake="PNHandshakeOperation",e.ReceiveMessages="PNReceiveMessagesOperation"}(A||(A={}));var j={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNRemoveUserOperation:"PNRemoveUserOperation",PNFetchUserOperation:"PNFetchUserOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNRemoveSpaceOperation:"PNRemoveSpaceOperation",PNFetchSpaceOperation:"PNFetchSpaceOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},x=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==j.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==j.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case j.PNPublishOperation:t="pub";break;case j.PNSignalOperation:t="sig";break;case j.PNHistoryOperation:case j.PNFetchMessagesOperation:case j.PNDeleteMessagesOperation:case j.PNMessageCounts:t="hist";break;case j.PNUnsubscribeOperation:case j.PNWhereNowOperation:case j.PNHereNowOperation:case j.PNHeartbeatOperation:case j.PNSetStateOperation:case j.PNGetStateOperation:t="pres";break;case j.PNAddChannelsToGroupOperation:case j.PNRemoveChannelsFromGroupOperation:case j.PNChannelGroupsOperation:case j.PNRemoveGroupOperation:case j.PNChannelsForGroupOperation:t="cg";break;case j.PNPushNotificationEnabledChannelsOperation:case j.PNRemoveAllPushNotificationsOperation:t="push";break;case j.PNCreateUserOperation:case j.PNUpdateUserOperation:case j.PNDeleteUserOperation:case j.PNGetUserOperation:case j.PNGetUsersOperation:case j.PNCreateSpaceOperation:case j.PNUpdateSpaceOperation:case j.PNDeleteSpaceOperation:case j.PNGetSpaceOperation:case j.PNGetSpacesOperation:case j.PNGetMembersOperation:case j.PNUpdateMembersOperation:case j.PNGetMembershipsOperation:case j.PNUpdateMembershipsOperation:t="obj";break;case j.PNAddMessageActionOperation:case j.PNRemoveMessageActionOperation:case j.PNGetMessageActionsOperation:t="msga";break;case j.PNAccessManagerGrant:case j.PNAccessManagerAudit:t="pam";break;case j.PNAccessManagerGrantToken:case j.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),I=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(I),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(I),F=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(I),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new D(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new F(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),L=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=U.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=U.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function q(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function z(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function V(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function W(e,t,n,r,i){var o=e.config,s=e.crypto,a=J(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(M.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function X(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return j.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(M.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return j.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return j.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(o),"/uuid/").concat(M.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var le=Object.freeze({__proto__:null,getOperation:function(){return j.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(M.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var pe=Object.freeze({__proto__:null,getOperation:function(){return j.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return j.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),de={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return j.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ye={getOperation:function(){return j.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(M.encodeString(t.channel),"/0/").concat(M.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,N,T,k,C,E,A,M,U,R,j,x,I,D,G,F,K,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",q("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",q("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(N=(w=l).POSTFILE,T=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,N.apply(w,T.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(C=(k=l).POSTFILE,E=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,C.apply(k,E.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,U=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,U.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(j=(R=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,j.apply(R,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(H=I.response,new Promise((function(e){var t="";H.on("data",(function(e){t+=e.toString("utf8")})),H.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);F=u.fileUploadPublishRetryLimit,K=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),K=!0,[3,26];case 25:return o.sent(),F-=1,[3,26];case 26:if(!K&&F>0)return[3,23];o.label=27;case 27:if(K)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var H}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",q("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",q("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",q("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(M.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=V(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&W(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},me={getOperation:function(){return j.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},_e={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},Oe={getOperation:function(){return j.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Pe={getOperation:function(){return j.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return j.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return j.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return j.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return j.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return j.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return j.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return j.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return j.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return j.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ue={getOperation:function(){return j.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Re=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var je=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function xe(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function Ie(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function De(e,t){if(xe(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=Ie(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=Ie(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=Ie(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=Ie(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=Ie(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=Ie(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=Ie(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=Ie(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=Ie(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=Ie(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=Ie(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=Ie(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var Ge=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrantToken},extractPermissions:Ie,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return xe(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return De(0,t)},handleResponse:function(e,t){return t.data.token}}),Fe={getOperation:function(){return j.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(M.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Le=Object.freeze({__proto__:null,getOperation:function(){return j.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(M.encodeString(r),"/0/").concat(M.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return j.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(M.encodeString(i),"/0/").concat(M.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var qe=Object.freeze({__proto__:null,getOperation:function(){return j.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(M.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return j.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(M.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return j.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(M.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Je=Object.freeze({__proto__:null,getOperation:function(){return j.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(M.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var We=Object.freeze({__proto__:null,getOperation:function(){return j.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var Xe=Object.freeze({__proto__:null,getOperation:function(){return j.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),$e={getOperation:function(){return j.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Qe={getOperation:function(){return j.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(ht.type,ut((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ft.type,ut((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Ct())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(Tt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(kt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(dt.type,ut((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r.metadata))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(tt),Mt=new Ze("STOPPED");Mt.on(gt.type,(function(e,t){return Mt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(vt.type,(function(e){return Gt.with(n({},e))}));var Ut=new Ze("HANDSHAKE_FAILURE");Ut.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),Ut.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Rt=new Ze("STOPPED");Rt.on(gt.type,(function(e,t){return Rt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(vt.type,(function(e){return It.with(n({},e))}));var jt=new Ze("RECEIVE_FAILURE");jt.on(Et.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),jt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ze("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ft(e)})),xt.onExit((function(){return ft.cancel})),xt.on(Tt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),xt.on(kt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Ct.type,(function(e){return jt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason})})),xt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onEnter((function(e){return ht({category:"PNConnectedCategory"})})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[pt(t.payload.events)])})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Ft.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Gt=new Ze("HANDSHAKING");Gt.onEnter((function(e){return ct(e.channels,e.groups)})),Gt.onExit((function(){return ct.cancel})),Gt.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Ft.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Ft=new Ze("UNSUBSCRIBED");Ft.on(gt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Kt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Ft,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(gt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(vt())},e.prototype.disconnect=function(){this.engine.transition(yt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new g({setup:e});this._config=o;var c=new N({config:o}),l=e.cryptography;r.init(o);var p=new H(o,i);this._tokenManager=p;var h=new x({maximumSamplesCount:6e4});this._telemetryManager=h;var f={config:o,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return l.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return l.decryptFile(e,n,t.File)};var d=X.bind(this,f,We),y=X.bind(this,f,oe),v=X.bind(this,f,ae),b=X.bind(this,f,ce),m=X.bind(this,f,Xe),_=new L;if(this._listenerManager=_,this.iAmHere=X.bind(this,f,ae),this.iAmAway=X.bind(this,f,oe),this.setPresenceState=X.bind(this,f,ce),this.handshake=X.bind(this,f,$e),this.receiveMessages=X.bind(this,f,Qe),!0===o.enableSubscribeBeta){var O=new Kt({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return 25*e},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return t<3},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;_.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){_.announceStatus(e)}});this.subscribe=O.subscribe.bind(O),this.unsubscribe=O.unsubscribe.bind(O),this.eventEngine=O}else{var P=new R({timeEndpoint:d,leaveEndpoint:y,heartbeatEndpoint:v,setStateEndpoint:b,subscribeEndpoint:m,crypto:f.crypto,config:f.config,listenerManager:_,getFileUrl:function(e){return be(f,e)}});this.subscribe=P.adaptSubscribeChange.bind(P),this.unsubscribe=P.adaptUnsubscribeChange.bind(P),this.disconnect=P.disconnect.bind(P),this.reconnect=P.reconnect.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.setState=P.adaptStateChange.bind(P),this.presence=P.adaptPresenceChange.bind(P),this.destroy=function(e){P.unsubscribeAll(e),P.disconnect()}}this.addListener=_.addListener.bind(_),this.removeListener=_.removeListener.bind(_),this.removeAllListeners=_.removeAllListeners.bind(_),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:X.bind(this,f,Z),listChannels:X.bind(this,f,ee),addChannels:X.bind(this,f,$),removeChannels:X.bind(this,f,Q),deleteGroup:X.bind(this,f,Y)},this.push={addChannels:X.bind(this,f,te),removeChannels:X.bind(this,f,ne),deleteDevice:X.bind(this,f,ie),listChannels:X.bind(this,f,re)},this.hereNow=X.bind(this,f,le),this.whereNow=X.bind(this,f,se),this.getState=X.bind(this,f,ue),this.grant=X.bind(this,f,je),this.grantToken=X.bind(this,f,Ge),this.audit=X.bind(this,f,Re),this.revokeToken=X.bind(this,f,Fe),this.publish=X.bind(this,f,Le),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=X.bind(this,f,He),this.history=X.bind(this,f,qe),this.deleteMessages=X.bind(this,f,ze),this.messageCounts=X.bind(this,f,Ve),this.fetchMessages=X.bind(this,f,Je),this.addMessageAction=X.bind(this,f,pe),this.removeMessageAction=X.bind(this,f,he),this.getMessageActions=X.bind(this,f,fe),this.listFiles=X.bind(this,f,de);var S=X.bind(this,f,ge);this.publishFile=X.bind(this,f,ye),this.sendFile=ve({generateUploadUrl:S,publishFile:this.publishFile,modules:f}),this.getFileUrl=function(e){return be(f,e)},this.downloadFile=X.bind(this,f,me),this.deleteFile=X.bind(this,f,_e),this.objects={getAllUUIDMetadata:X.bind(this,f,Oe),getUUIDMetadata:X.bind(this,f,Pe),setUUIDMetadata:X.bind(this,f,Se),removeUUIDMetadata:X.bind(this,f,we),getAllChannelMetadata:X.bind(this,f,Ne),getChannelMetadata:X.bind(this,f,Te),setChannelMetadata:X.bind(this,f,ke),removeChannelMetadata:X.bind(this,f,Ce),getChannelMembers:X.bind(this,f,Ee),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return U.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return U.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return U.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return U.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return U.PNNetworkIssuesCategory;if(e.timeout)return U.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return U.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return U.PNBadRequestCategory;if(e.response.forbidden)return U.PNAccessDeniedCategory}return U.PNUnknownCategory},e}();function Bt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?Bt(s):s})),n}var qt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),zt={exports:{}},Vt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function rn(e,t,n,r){void 0===r&&(r=Yt());var i,o=on(e,"",0,[],void 0,0,r)||e;try{i=0===Qt.length?JSON.stringify(o,t,n):JSON.stringify(o,sn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==$t.length;){var s=$t.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function on(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(fn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===pn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=dn[u]:u<2048?s+=dn[192|u>>6]+dn[128|63&u]:u<55296||u>=57344?s+=dn[224|u>>12]+dn[128|u>>6&63]+dn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=dn[240|u>>18]+dn[128|u>>12&63]+dn[128|u>>6&63]+dn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(fn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(On(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},xn=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&An.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},In={formats:ln,parse:function(e,t){var n=function(e){if(!e)return Un;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?Un.charset:e.charset;return{allowDots:void 0===e.allowDots?Un.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:Un.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:Un.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Un.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:Un.comma,decoder:"function"==typeof e.decoder?e.decoder:Un.decoder,delimiter:"string"==typeof e.delimiter||En.isRegExp(e.delimiter)?e.delimiter:Un.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:Un.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:Un.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:Un.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:Un.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Un.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Mn(l)?[l]:l),An.call(r,c)?r[c]=En.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Dn(e){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dn(e)}var Gn=function(e){return null!==e&&"object"===Dn(e)};function Fn(e){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fn(e)}var Kn=Gn,Ln=Hn;function Hn(e){if(e)return function(e){for(var t in Hn.prototype)Object.prototype.hasOwnProperty.call(Hn.prototype,t)&&(e[t]=Hn.prototype[t]);return e}(e)}Hn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Hn.prototype.parse=function(e){return this._parser=e,this},Hn.prototype.responseType=function(e){return this._responseType=e,this},Hn.prototype.serialize=function(e){return this._serializer=e,this},Hn.prototype.timeout=function(e){if(!e||"object"!==Fn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Hn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var Bn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),qn=new Set([408,413,429,500,502,503,504,521,522,524]);Hn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&qn.has(t.status))return!0;if(e){if(e.code&&Bn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Hn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Hn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Hn.prototype.catch=function(e){return this.then(void 0,e)},Hn.prototype.use=function(e){return e(this),this},Hn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Hn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Hn.prototype.get=function(e){return this._header[e.toLowerCase()]},Hn.prototype.getHeader=Hn.prototype.get,Hn.prototype.set=function(e,t){if(Kn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Hn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Hn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Kn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Hn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Hn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Hn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Hn.prototype.redirects=function(e){return this._maxRedirects=e,this},Hn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Hn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Hn.prototype.send=function(e){var t=Kn(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Kn(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Hn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Hn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Hn.prototype._appendQueryString=function(){console.warn("Unsupported")},Hn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Hn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var zn={};function Vn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(zt,zt.exports);var tr=zt.exports;function nr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function rr(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(nr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:U.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function ir(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=tr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function or(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function sr(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function ar(e,t,n,r){var i=tr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function ur(e,t,n,r){var i=tr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function cr(e,t,n){var r=tr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function lr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var pr,hr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=lr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=lr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),fr=(pr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),pr.supportsFile="undefined"!=typeof File,pr.supportsBlob="undefined"!=typeof Blob,pr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,pr.supportsBuffer=!1,pr.supportsStream=!1,pr.supportsString=!0,pr.supportsEncryptFile=!0,pr.supportsFileUri=!1,pr);function dr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var gr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:cr,get:sr,post:ar,patch:ur,sendBeacon:dr,getfile:or,postfile:ir}),t.cbor=new qt((function(e){return Bt(p.decode(e))}),y),t.PubNubFile=fr,t.cryptography=new hr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Lt);return gr})); diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index 6611326ce..253e1ab10 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -33,6 +33,17 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; @@ -171,7 +182,32 @@ var default_1 = /** @class */ (function () { this.handshake = endpoint_1.default.bind(this, modules, handshake_1.default); this.receiveMessages = endpoint_1.default.bind(this, modules, receiveMessages_1.default); if (config.enableSubscribeBeta === true) { - var eventEngine = new event_engine_1.EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages }); + var eventEngine = new event_engine_1.EventEngine({ + handshake: this.handshake, + receiveEvents: this.receiveMessages, + getRetryDelay: function (attempts) { return attempts * 25; }, + delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, + shouldRetry: function (error, attempts) { return attempts < 3; }, + emitEvents: function (events) { + var e_1, _a; + try { + for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { + var event_1 = events_1_1.value; + listenerManager.announceMessage(event_1); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1); + } + finally { if (e_1) throw e_1.error; } + } + }, + emitStatus: function (status) { + listenerManager.announceStatus(status); + }, + }); this.subscribe = eventEngine.subscribe.bind(eventEngine); this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); this.eventEngine = eventEngine; diff --git a/lib/event-engine/core/dispatcher.js b/lib/event-engine/core/dispatcher.js index 948f89130..056a97830 100644 --- a/lib/event-engine/core/dispatcher.js +++ b/lib/event-engine/core/dispatcher.js @@ -1,5 +1,32 @@ "use strict"; /* eslint-disable @typescript-eslint/no-explicit-any */ +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.Dispatcher = void 0; var Dispatcher = /** @class */ (function () { @@ -30,6 +57,23 @@ var Dispatcher = /** @class */ (function () { } instance.start(); }; + Dispatcher.prototype.dispose = function () { + var e_1, _a; + try { + for (var _b = __values(this.instances.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { + var _d = __read(_c.value, 2), key = _d[0], instance = _d[1]; + instance.cancel(); + this.instances.delete(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + }; return Dispatcher; }()); exports.Dispatcher = Dispatcher; diff --git a/lib/event-engine/core/handler.js b/lib/event-engine/core/handler.js index 59cc224ce..f5446b05f 100644 --- a/lib/event-engine/core/handler.js +++ b/lib/event-engine/core/handler.js @@ -34,7 +34,10 @@ var AsyncHandler = /** @class */ (function (_super) { return _this; } AsyncHandler.prototype.start = function () { - this.asyncFunction(this.payload, this.abortSignal, this.dependencies); + this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch(function (error) { + // console.log('Unhandled error:', error); + // swallow the error + }); }; AsyncHandler.prototype.cancel = function () { this.abortSignal.abort(); diff --git a/lib/event-engine/dispatcher.js b/lib/event-engine/dispatcher.js index 1a39d5e78..7e20ccf2d 100644 --- a/lib/event-engine/dispatcher.js +++ b/lib/event-engine/dispatcher.js @@ -144,7 +144,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { if (error_1 instanceof Error && error_1.message === 'Aborted') { return [2 /*return*/]; } - if (error_1 instanceof endpoint_1.PubNubError) { + if (error_1 instanceof endpoint_1.PubNubError && !abortSignal.aborted) { return [2 /*return*/, engine.transition(events.receivingFailure(error_1))]; } return [3 /*break*/, 4]; @@ -154,16 +154,25 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); })); _this.on(effects.emitEvents.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents; + var emitEvents = _a.emitEvents; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { if (payload.length > 0) { - console.log(payload); + emitEvents(payload); } return [2 /*return*/]; }); }); })); + _this.on(effects.emitStatus.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { + var emitStatus = _a.emitStatus; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + emitStatus(payload); + return [2 /*return*/]; + }); + }); + })); _this.on(effects.reconnect.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { var receiveEvents = _a.receiveEvents, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; return __awaiter(_this, void 0, void 0, function () { @@ -231,7 +240,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { })]; case 3: result = _b.sent(); - return [2 /*return*/, engine.transition(events.handshakingReconnectingSuccess(result.metadata))]; + return [2 /*return*/, engine.transition(events.handshakingReconnectingSuccess(result))]; case 4: error_3 = _b.sent(); if (error_3 instanceof Error && error_3.message === 'Aborted') { diff --git a/lib/event-engine/effects.js b/lib/event-engine/effects.js index 35ea2dea0..02875a14b 100644 --- a/lib/event-engine/effects.js +++ b/lib/event-engine/effects.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.handshakeReconnect = exports.reconnect = exports.emitEvents = exports.receiveEvents = exports.handshake = void 0; +exports.handshakeReconnect = exports.reconnect = exports.emitStatus = exports.emitEvents = exports.receiveEvents = exports.handshake = void 0; var core_1 = require("./core"); exports.handshake = (0, core_1.createManagedEffect)('HANDSHAKE', function (channels, groups) { return ({ channels: channels, @@ -8,5 +8,6 @@ exports.handshake = (0, core_1.createManagedEffect)('HANDSHAKE', function (chann }); }); exports.receiveEvents = (0, core_1.createManagedEffect)('RECEIVE_EVENTS', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); exports.emitEvents = (0, core_1.createEffect)('EMIT_EVENTS', function (events) { return events; }); -exports.reconnect = (0, core_1.createManagedEffect)('RECONNECT', function (context) { return context; }); +exports.emitStatus = (0, core_1.createEffect)('EMIT_STATUS', function (status) { return status; }); +exports.reconnect = (0, core_1.createManagedEffect)('RECEIVE_RECONNECT', function (context) { return context; }); exports.handshakeReconnect = (0, core_1.createManagedEffect)('HANDSHAKE_RECONNECT', function (context) { return context; }); diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index aa82df0d0..88ae4af65 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -27,10 +27,10 @@ exports.receivingSuccess = (0, core_1.createEvent)('RECEIVING_SUCCESS', function events: events, }); }); exports.receivingFailure = (0, core_1.createEvent)('RECEIVING_FAILURE', function (error) { return error; }); -exports.reconnectingSuccess = (0, core_1.createEvent)('RECONNECTING_SUCCESS', function (cursor, events) { return ({ +exports.reconnectingSuccess = (0, core_1.createEvent)('RECEIVING_RECONNECTING_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); -exports.reconnectingFailure = (0, core_1.createEvent)('RECONNECTING_FAILURE', function (error) { return error; }); -exports.reconnectingGiveup = (0, core_1.createEvent)('RECONNECTING_GIVEUP', function () { return ({}); }); -exports.reconnectingRetry = (0, core_1.createEvent)('RECONNECTING_RETRY', function () { return ({}); }); +exports.reconnectingFailure = (0, core_1.createEvent)('RECEIVING_RECONNECTING_FAILURE', function (error) { return error; }); +exports.reconnectingGiveup = (0, core_1.createEvent)('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); +exports.reconnectingRetry = (0, core_1.createEvent)('RECEIVING_RECONNECTING_RETRY', function () { return ({}); }); diff --git a/lib/event-engine/index.js b/lib/event-engine/index.js index e5c655e05..a8dc852b4 100644 --- a/lib/event-engine/index.js +++ b/lib/event-engine/index.js @@ -60,7 +60,7 @@ var EventEngine = /** @class */ (function () { this.channels = []; this.groups = []; this.dispatcher = new dispatcher_1.EventEngineDispatcher(this.engine, dependencies); - this.engine.subscribe(function (change) { + this._unsubscribeEngine = this.engine.subscribe(function (change) { if (change.type === 'invocationDispatched') { _this.dispatcher.dispatch(change.invocation); } @@ -97,6 +97,11 @@ var EventEngine = /** @class */ (function () { EventEngine.prototype.disconnect = function () { this.engine.transition(events.disconnect()); }; + EventEngine.prototype.dispose = function () { + this.disconnect(); + this._unsubscribeEngine(); + this.dispatcher.dispose(); + }; return EventEngine; }()); exports.EventEngine = EventEngine; diff --git a/lib/event-engine/states/handshake_failure.js b/lib/event-engine/states/handshake_failure.js index 2e2365a4d..e6295d151 100644 --- a/lib/event-engine/states/handshake_failure.js +++ b/lib/event-engine/states/handshake_failure.js @@ -13,10 +13,12 @@ var __assign = (this && this.__assign) || function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.HandshakeFailureState = void 0; var state_1 = require("../core/state"); +var effects_1 = require("../effects"); var events_1 = require("../events"); var handshake_reconnecting_1 = require("./handshake_reconnecting"); var handshake_stopped_1 = require("./handshake_stopped"); exports.HandshakeFailureState = new state_1.State('HANDSHAKE_FAILURE'); +exports.HandshakeFailureState.onEnter(function (context) { return (0, effects_1.emitStatus)({ category: 'PNNetworkIssuesCategory' }); }); exports.HandshakeFailureState.on(events_1.handshakingReconnectingRetry.type, function (context) { return handshake_reconnecting_1.HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); }); diff --git a/lib/event-engine/states/handshake_reconnecting.js b/lib/event-engine/states/handshake_reconnecting.js index 272d114f0..c5f575cea 100644 --- a/lib/event-engine/states/handshake_reconnecting.js +++ b/lib/event-engine/states/handshake_reconnecting.js @@ -20,18 +20,18 @@ var handshake_stopped_1 = require("./handshake_stopped"); var receiving_1 = require("./receiving"); exports.HandshakeReconnectingState = new state_1.State('HANDSHAKE_RECONNECTING'); exports.HandshakeReconnectingState.onEnter(function (context) { return (0, effects_1.handshakeReconnect)(context); }); -exports.HandshakeReconnectingState.onExit(function () { return effects_1.reconnect.cancel; }); -exports.HandshakeReconnectingState.on(events_1.reconnectingSuccess.type, function (context, event) { +exports.HandshakeReconnectingState.onExit(function () { return effects_1.handshakeReconnect.cancel; }); +exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingSuccess.type, function (context, event) { return receiving_1.ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor, - }, [(0, effects_1.emitEvents)(event.payload.events)]); + }); }); -exports.HandshakeReconnectingState.on(events_1.reconnectingFailure.type, function (context, event) { +exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingFailure.type, function (context, event) { return exports.HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); }); -exports.HandshakeReconnectingState.on(events_1.reconnectingGiveup.type, function (context) { +exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingGiveup.type, function (context) { return handshake_failure_1.HandshakeFailureState.with({ groups: context.groups, channels: context.channels, diff --git a/lib/event-engine/states/receiving.js b/lib/event-engine/states/receiving.js index e28b080df..2128e2fd4 100644 --- a/lib/event-engine/states/receiving.js +++ b/lib/event-engine/states/receiving.js @@ -20,6 +20,7 @@ var receive_reconnecting_1 = require("./receive_reconnecting"); var receive_stopped_1 = require("./receive_stopped"); exports.ReceivingState = new state_1.State('RECEIVING'); exports.ReceivingState.onEnter(function (context) { return (0, effects_1.receiveEvents)(context.channels, context.groups, context.cursor); }); +exports.ReceivingState.onEnter(function (context) { return (0, effects_1.emitStatus)({ category: 'PNConnectedCategory' }); }); exports.ReceivingState.onExit(function () { return effects_1.receiveEvents.cancel; }); exports.ReceivingState.on(events_1.receivingSuccess.type, function (context, event) { return exports.ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [(0, effects_1.emitEvents)(event.payload.events)]); diff --git a/package-lock.json b/package-lock.json index 789d48f12..f0625d0f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pubnub", - "version": "7.2.0", + "version": "7.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pubnub", - "version": "7.2.0", + "version": "7.2.2", "license": "MIT", "dependencies": { "agentkeepalive": "^3.5.2", @@ -29,6 +29,7 @@ "@types/expect": "^24.3.0", "@types/mocha": "^9.1.0", "@types/nock": "^9.3.1", + "@types/node-fetch": "^2.6.3", "@types/pubnub": "^7.2.0", "@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/parser": "^5.12.1", @@ -36,7 +37,7 @@ "chai-as-promised": "^7.1.1", "chai-nock": "^1.2.0", "cucumber-pretty": "^6.0.1", - "cucumber-tsflow": "^4.0.0-preview.7", + "cucumber-tsflow": "^4.0.0-rc.11", "es6-shim": "^0.35.6", "eslint": "^8.9.0", "eslint-plugin-mocha": "^10.0.3", @@ -52,7 +53,7 @@ "karma-spec-reporter": "0.0.32", "mocha": "^9.2.1", "nock": "^9.6.1", - "node-fetch": "^2.6.1", + "node-fetch": "^2.6.9", "phantomjs-prebuilt": "^2.1.16", "prettier": "^2.5.1", "rimraf": "^3.0.2", @@ -117,6 +118,16 @@ "node": ">=6.9.0" } }, + "node_modules/@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -138,6 +149,39 @@ "@cucumber/messages": "^16.0.0" } }, + "node_modules/@cucumber/create-meta/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/create-meta/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/create-meta/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/create-meta/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/cucumber": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/@cucumber/cucumber/-/cucumber-7.3.2.tgz", @@ -194,6 +238,54 @@ "regexp-match-indices": "1.0.2" } }, + "node_modules/@cucumber/cucumber/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/cucumber/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/cucumber/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/cucumber/node_modules/cli-table3": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", + "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0" + }, + "engines": { + "node": "10.* || >= 12.*" + }, + "optionalDependencies": { + "colors": "1.4.0" + } + }, + "node_modules/@cucumber/cucumber/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/gherkin": { "version": "19.0.3", "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-19.0.3.tgz", @@ -220,6 +312,30 @@ "gherkin-javascript": "bin/gherkin" } }, + "node_modules/@cucumber/gherkin-streams/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/gherkin-streams/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/gherkin-streams/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, "node_modules/@cucumber/gherkin-streams/node_modules/source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -230,6 +346,48 @@ "source-map": "^0.6.0" } }, + "node_modules/@cucumber/gherkin-streams/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@cucumber/gherkin/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/gherkin/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/gherkin/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/gherkin/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/html-formatter": { "version": "15.0.2", "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-15.0.2.tgz", @@ -244,6 +402,30 @@ "cucumber-html-formatter": "bin/cucumber-html-formatter.js" } }, + "node_modules/@cucumber/html-formatter/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/html-formatter/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/html-formatter/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, "node_modules/@cucumber/html-formatter/node_modules/source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -254,6 +436,15 @@ "source-map": "^0.6.0" } }, + "node_modules/@cucumber/html-formatter/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/message-streams": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", @@ -263,7 +454,7 @@ "@cucumber/messages": "^16.0.1" } }, - "node_modules/@cucumber/messages": { + "node_modules/@cucumber/message-streams/node_modules/@cucumber/messages": { "version": "16.0.1", "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", @@ -275,6 +466,40 @@ "uuid": "8.3.2" } }, + "node_modules/@cucumber/message-streams/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/message-streams/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/message-streams/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@cucumber/messages": { + "version": "21.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-21.0.1.tgz", + "integrity": "sha512-pGR7iURM4SF9Qp1IIpNiVQ77J9kfxMkPOEbyy+zRmGABnWWCsqMpJdfHeh9Mb3VskemVw85++e15JT0PYdcR3g==", + "dev": true, + "peer": true, + "dependencies": { + "@types/uuid": "8.3.4", + "class-transformer": "0.5.1", + "reflect-metadata": "0.1.13", + "uuid": "9.0.0" + } + }, "node_modules/@cucumber/pretty-formatter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", @@ -309,24 +534,51 @@ "integrity": "sha512-OGCXaJ1BQXmQ5b9pw+JYsBGumK2/LPZiLmbj1o1JFVeSNs2PY8WPQFSyXrskhrHz5Nd/6lYg7lvGMtFHOncC4w==", "dev": true }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", + "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.1.0.tgz", - "integrity": "sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", + "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", - "ignore": "^4.0.6", + "espree": "^9.5.1", + "globals": "^13.19.0", + "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/eslintrc/node_modules/argparse": { @@ -335,30 +587,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/eslintrc/node_modules/ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -371,20 +599,42 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/@eslint/js": { + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", + "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", - "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.4" + "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -789,6 +1039,30 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, + "node_modules/@types/node-fetch": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", + "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", + "dev": true, + "dependencies": { + "@types/node": "*", + "form-data": "^3.0.0" + } + }, + "node_modules/@types/node-fetch/node_modules/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/@types/pubnub": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", @@ -811,10 +1085,11 @@ "dev": true }, "node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", + "dev": true, + "peer": true }, "node_modules/@types/yargs": { "version": "16.0.4", @@ -864,39 +1139,6 @@ } } }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/@typescript-eslint/parser": { "version": "5.12.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.12.1.tgz", @@ -1007,39 +1249,6 @@ } } }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/@typescript-eslint/utils": { "version": "5.12.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.12.1.tgz", @@ -1123,9 +1332,9 @@ } }, "node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", "bin": { "acorn": "bin/acorn" }, @@ -1713,15 +1922,16 @@ } }, "node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", + "dev": true, + "peer": true }, "node_modules/cli-table3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", - "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", + "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", "dev": true, "dependencies": { "string-width": "^4.2.0" @@ -1730,7 +1940,7 @@ "node": "10.* || >= 12.*" }, "optionalDependencies": { - "colors": "1.4.0" + "@colors/colors": "1.5.0" } }, "node_modules/cliui": { @@ -2024,15 +2234,18 @@ "peer": true }, "node_modules/cucumber-tsflow": { - "version": "4.0.0-preview.7", - "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-preview.7.tgz", - "integrity": "sha512-gG51EelraRDM+B3/tShrs+71/2A20IRblXFGT6W6+5qhEtykep7rYOs+wFL1YQ5FFmGCiZISoRI4KucPgcqhOw==", + "version": "4.0.0-rc.11", + "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-rc.11.tgz", + "integrity": "sha512-VK/RhJOOxS4KAH6UIkfLsDE2+H7OtP/+cwzx139gldqHP08hoYk/fMwOoXlGWXOOX2O3amJ6RTS0YMF2xCA8Bw==", "dev": true, "dependencies": { "callsites": "^3.1.0", "log4js": "^6.3.0", "source-map-support": "^0.5.19", "underscore": "^1.8.3" + }, + "peerDependencies": { + "@cucumber/cucumber": ">7.0.0-rc || >7.0.0" } }, "node_modules/cucumber/node_modules/ansi-regex": { @@ -2456,12 +2669,12 @@ "dev": true }, "node_modules/error-stack-parser": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.7.tgz", - "integrity": "sha512-chLOW0ZGRf4s8raLrDxa5sdkvPec5YdvwbFnqJme4rk0rFajP8mPtrDL1+I+CwrQDCjswDA5sREX7jYQDQs9vA==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", + "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", "dev": true, "dependencies": { - "stackframe": "^1.1.1" + "stackframe": "^1.3.4" } }, "node_modules/es5-ext": { @@ -2562,13 +2775,18 @@ } }, "node_modules/eslint": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", - "integrity": "sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q==", - "dev": true, - "dependencies": { - "@eslint/eslintrc": "^1.1.0", - "@humanwhocodes/config-array": "^0.9.2", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", + "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.2", + "@eslint/js": "8.37.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -2576,32 +2794,32 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", - "esquery": "^1.4.0", + "eslint-visitor-keys": "^3.4.0", + "espree": "^9.5.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" @@ -2691,12 +2909,15 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", + "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/ansi-styles": { @@ -2778,21 +2999,6 @@ "node": ">=10.13.0" } }, - "node_modules/eslint/node_modules/globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/eslint/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -2878,17 +3084,20 @@ } }, "node_modules/espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", + "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", "dev": true, "dependencies": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.3.0" + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/esprima": { @@ -2904,9 +3113,9 @@ } }, "node_modules/esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { "estraverse": "^5.1.0" @@ -3173,6 +3382,22 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -3450,6 +3675,21 @@ "node": ">= 6" } }, + "node_modules/globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -3475,6 +3715,12 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, + "node_modules/grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, "node_modules/growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -3889,6 +4135,15 @@ "node": ">=0.12.0" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -4287,6 +4542,16 @@ "node": ">=8" } }, + "node_modules/js-sdsl": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", + "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4537,6 +4802,21 @@ "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", "integrity": "sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY=" }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -4908,22 +5188,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/mocha/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -4945,21 +5209,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/mocha/node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/mocha/node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -4978,45 +5227,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "node_modules/mocha/node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/mocha/node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -5228,9 +5438,9 @@ } }, "node_modules/node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", "dev": true, "dependencies": { "whatwg-url": "^5.0.0" @@ -5336,6 +5546,36 @@ "node": ">= 0.8.0" } }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/pac-proxy-agent": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", @@ -5413,6 +5653,15 @@ "node": ">= 0.8" } }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -5784,9 +6033,9 @@ "dev": true }, "node_modules/regenerator-runtime": { - "version": "0.13.10", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", - "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==", + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", "dev": true, "peer": true }, @@ -6085,6 +6334,36 @@ "integrity": "sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ=", "dev": true }, + "node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/serialize-error": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", @@ -6434,9 +6713,9 @@ } }, "node_modules/stackframe": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.1.tgz", - "integrity": "sha512-h88QkzREN/hy8eRdyNhhsO7RSJ5oyTqxxmmn0dzBIMUclZsjpfmrsg81vp8mjjAs2vAZ72nyWxRUwSwmh0e4xg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", + "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==", "dev": true }, "node_modules/stacktrace-gps": { @@ -6647,17 +6926,6 @@ "node": ">= 6" } }, - "node_modules/superagent/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/superagent/node_modules/readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", @@ -6671,25 +6939,6 @@ "node": ">= 6" } }, - "node_modules/superagent/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/superagent/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -7195,20 +7444,15 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "dev": true, + "peer": true, "bin": { "uuid": "dist/bin/uuid" } }, - "node_modules/v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", @@ -7540,15 +7784,6 @@ "node": ">=6" } }, - "node_modules/yargs/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/yargs/node_modules/yargs-parser": { "version": "18.1.3", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", @@ -7638,6 +7873,13 @@ "regenerator-runtime": "^0.13.10" } }, + "@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true, + "optional": true + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -7654,6 +7896,38 @@ "dev": true, "requires": { "@cucumber/messages": "^16.0.0" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/cucumber": { @@ -7695,6 +7969,48 @@ "tmp": "^0.2.1", "util-arity": "^1.1.0", "verror": "^1.10.0" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "cli-table3": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", + "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "dev": true, + "requires": { + "colors": "1.4.0", + "string-width": "^4.2.0" + } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/cucumber-expressions": { @@ -7714,6 +8030,38 @@ "requires": { "@cucumber/message-streams": "^2.0.0", "@cucumber/messages": "^16.0.1" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/gherkin-streams": { @@ -7729,6 +8077,30 @@ "source-map-support": "0.5.19" }, "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, "source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -7738,6 +8110,12 @@ "buffer-from": "^1.0.0", "source-map": "^0.6.0" } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true } } }, @@ -7752,6 +8130,30 @@ "source-map-support": "0.5.19" }, "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, "source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", @@ -7761,6 +8163,12 @@ "buffer-from": "^1.0.0", "source-map": "^0.6.0" } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true } } }, @@ -7771,18 +8179,51 @@ "dev": true, "requires": { "@cucumber/messages": "^16.0.1" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "version": "21.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-21.0.1.tgz", + "integrity": "sha512-pGR7iURM4SF9Qp1IIpNiVQ77J9kfxMkPOEbyy+zRmGABnWWCsqMpJdfHeh9Mb3VskemVw85++e15JT0PYdcR3g==", "dev": true, + "peer": true, "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", + "@types/uuid": "8.3.4", + "class-transformer": "0.5.1", "reflect-metadata": "0.1.13", - "uuid": "8.3.2" + "uuid": "9.0.0" } }, "@cucumber/pretty-formatter": { @@ -7811,20 +8252,35 @@ "integrity": "sha512-OGCXaJ1BQXmQ5b9pw+JYsBGumK2/LPZiLmbj1o1JFVeSNs2PY8WPQFSyXrskhrHz5Nd/6lYg7lvGMtFHOncC4w==", "dev": true }, + "@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.3.0" + } + }, + "@eslint-community/regexpp": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", + "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", + "dev": true + }, "@eslint/eslintrc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.1.0.tgz", - "integrity": "sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", + "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", - "ignore": "^4.0.6", + "espree": "^9.5.1", + "globals": "^13.19.0", + "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "dependencies": { @@ -7834,21 +8290,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, "js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -7860,17 +8301,29 @@ } } }, + "@eslint/js": { + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", + "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", + "dev": true + }, "@humanwhocodes/config-array": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", - "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.4" + "minimatch": "^3.0.5" } }, + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true + }, "@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -8209,6 +8662,29 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, + "@types/node-fetch": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", + "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", + "dev": true, + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "@types/pubnub": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", @@ -8231,10 +8707,11 @@ "dev": true }, "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", + "dev": true, + "peer": true }, "@types/yargs": { "version": "16.0.4", @@ -8266,32 +8743,6 @@ "regexpp": "^3.2.0", "semver": "^7.3.5", "tsutils": "^3.21.0" - }, - "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - } } }, "@typescript-eslint/parser": { @@ -8346,32 +8797,6 @@ "is-glob": "^4.0.3", "semver": "^7.3.5", "tsutils": "^3.21.0" - }, - "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - } } }, "@typescript-eslint/utils": { @@ -8433,9 +8858,9 @@ } }, "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==" + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==" }, "acorn-jsx": { "version": "5.3.2", @@ -8887,18 +9312,19 @@ } }, "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", + "dev": true, + "peer": true }, "cli-table3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", - "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", + "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", "dev": true, "requires": { - "colors": "1.4.0", + "@colors/colors": "1.5.0", "string-width": "^4.2.0" } }, @@ -9216,9 +9642,9 @@ "peer": true }, "cucumber-tsflow": { - "version": "4.0.0-preview.7", - "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-preview.7.tgz", - "integrity": "sha512-gG51EelraRDM+B3/tShrs+71/2A20IRblXFGT6W6+5qhEtykep7rYOs+wFL1YQ5FFmGCiZISoRI4KucPgcqhOw==", + "version": "4.0.0-rc.11", + "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-rc.11.tgz", + "integrity": "sha512-VK/RhJOOxS4KAH6UIkfLsDE2+H7OtP/+cwzx139gldqHP08hoYk/fMwOoXlGWXOOX2O3amJ6RTS0YMF2xCA8Bw==", "dev": true, "requires": { "callsites": "^3.1.0", @@ -9508,12 +9934,12 @@ "dev": true }, "error-stack-parser": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.7.tgz", - "integrity": "sha512-chLOW0ZGRf4s8raLrDxa5sdkvPec5YdvwbFnqJme4rk0rFajP8mPtrDL1+I+CwrQDCjswDA5sREX7jYQDQs9vA==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", + "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", "dev": true, "requires": { - "stackframe": "^1.1.1" + "stackframe": "^1.3.4" } }, "es5-ext": { @@ -9598,13 +10024,18 @@ } }, "eslint": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", - "integrity": "sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q==", - "dev": true, - "requires": { - "@eslint/eslintrc": "^1.1.0", - "@humanwhocodes/config-array": "^0.9.2", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", + "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.2", + "@eslint/js": "8.37.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -9612,32 +10043,32 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", - "esquery": "^1.4.0", + "eslint-visitor-keys": "^3.4.0", + "espree": "^9.5.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "dependencies": { "ansi-styles": { @@ -9695,15 +10126,6 @@ "is-glob": "^4.0.3" } }, - "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -9816,20 +10238,20 @@ } }, "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", + "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", "dev": true }, "espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", + "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", "dev": true, "requires": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.3.0" + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.0" } }, "esprima": { @@ -9838,9 +10260,9 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -10071,6 +10493,16 @@ } } }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, "flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -10284,6 +10716,15 @@ "is-glob": "^4.0.1" } }, + "globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -10303,6 +10744,12 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, + "grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -10606,6 +11053,12 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, "is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -10901,6 +11354,12 @@ } } }, + "js-sdsl": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", + "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", + "dev": true + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -11122,6 +11581,15 @@ "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", "integrity": "sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY=" }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -11406,16 +11874,6 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -11431,15 +11889,6 @@ "argparse": "^2.0.1" } }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -11455,30 +11904,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, "serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -11654,9 +12079,9 @@ } }, "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", "dev": true, "requires": { "whatwg-url": "^5.0.0" @@ -11727,6 +12152,24 @@ "word-wrap": "~1.2.3" } }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, "pac-proxy-agent": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", @@ -11789,6 +12232,12 @@ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -12069,9 +12518,9 @@ "dev": true }, "regenerator-runtime": { - "version": "0.13.10", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", - "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==", + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", "dev": true, "peer": true }, @@ -12289,6 +12738,29 @@ "integrity": "sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ=", "dev": true }, + "semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "requires": { + "lru-cache": "^6.0.0" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, "serialize-error": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", @@ -12599,9 +13071,9 @@ } }, "stackframe": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.1.tgz", - "integrity": "sha512-h88QkzREN/hy8eRdyNhhsO7RSJ5oyTqxxmmn0dzBIMUclZsjpfmrsg81vp8mjjAs2vAZ72nyWxRUwSwmh0e4xg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", + "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==", "dev": true }, "stacktrace-gps": { @@ -12761,14 +13233,6 @@ "mime-types": "^2.1.12" } }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "requires": { - "yallist": "^4.0.0" - } - }, "readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", @@ -12778,19 +13242,6 @@ "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "requires": { - "lru-cache": "^6.0.0" - } - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } } }, @@ -13191,16 +13642,11 @@ "dev": true }, "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - }, - "v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true, + "peer": true }, "v8-compile-cache-lib": { "version": "3.0.1", @@ -13418,12 +13864,6 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, "yargs-parser": { "version": "18.1.3", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", diff --git a/package.json b/package.json index edfc5f23d..ddfc2e5d3 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,9 @@ "test:feature:objectsv2:node": "ts-mocha -p tsconfig.mocha.json --no-config --require test/setup.js --reporter spec test/dist/objectsv2.test.js", "test:feature:fileupload:node": "ts-mocha -p tsconfig.mocha.json --no-config --require test/setup.js --reporter spec test/feature/file_upload.node.test.js", "test:contract": "npm run test:contract:prepare && npm run test:contract:start", - "test:contract:prepare": "rimraf test/specs && git clone --branch master git@github.com:pubnub/sdk-specifications.git test/specs", + "test:contract:prepare": "rimraf test/specs && git clone --branch master --depth 1 git@github.com:pubnub/sdk-specifications.git test/specs", "test:contract:start": "cucumber-js -p default --tags 'not @na=js and not @beta and not @skip'", + "test:contract:beta": "cucumber-js -p default --tags 'not @na=js and @beta and not @skip'", "contract:refresh": "rimraf dist/contract && git clone --branch master git@github.com:pubnub/service-contract-mock.git dist/contract && npm install --prefix dist/contract && npm run refresh-files --prefix dist/contract", "contract:server": "npm start --prefix dist/contract consumer", "contract:build": "cd test/contract && tsc", @@ -70,6 +71,7 @@ "@types/expect": "^24.3.0", "@types/mocha": "^9.1.0", "@types/nock": "^9.3.1", + "@types/node-fetch": "^2.6.3", "@types/pubnub": "^7.2.0", "@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/parser": "^5.12.1", @@ -77,7 +79,7 @@ "chai-as-promised": "^7.1.1", "chai-nock": "^1.2.0", "cucumber-pretty": "^6.0.1", - "cucumber-tsflow": "^4.0.0-preview.7", + "cucumber-tsflow": "^4.0.0-rc.11", "es6-shim": "^0.35.6", "eslint": "^8.9.0", "eslint-plugin-mocha": "^10.0.3", @@ -93,7 +95,7 @@ "karma-spec-reporter": "0.0.32", "mocha": "^9.2.1", "nock": "^9.6.1", - "node-fetch": "^2.6.1", + "node-fetch": "^2.6.9", "phantomjs-prebuilt": "^2.1.16", "prettier": "^2.5.1", "rimraf": "^3.0.2", diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 89da7e91f..8b9bc6f1f 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -320,7 +320,21 @@ export default class { this.receiveMessages = endpointCreator.bind(this, modules, receiveMessagesConfig); if (config.enableSubscribeBeta === true) { - const eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages }); + const eventEngine = new EventEngine({ + handshake: this.handshake, + receiveEvents: this.receiveMessages, + getRetryDelay: (attempts) => attempts * 25, + delay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), + shouldRetry: (error, attempts) => attempts < 3, + emitEvents: (events) => { + for (const event of events) { + listenerManager.announceMessage(event); + } + }, + emitStatus: (status) => { + listenerManager.announceStatus(status); + }, + }); this.subscribe = eventEngine.subscribe.bind(eventEngine); this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); diff --git a/src/event-engine/core/dispatcher.ts b/src/event-engine/core/dispatcher.ts index c10bb5b46..598295d83 100644 --- a/src/event-engine/core/dispatcher.ts +++ b/src/event-engine/core/dispatcher.ts @@ -49,4 +49,11 @@ export class Dispatcher< instance.start(); } + + dispose() { + for (const [key, instance] of this.instances.entries()) { + instance.cancel(); + this.instances.delete(key); + } + } } diff --git a/src/event-engine/core/handler.ts b/src/event-engine/core/handler.ts index a419ea80f..041eba17b 100644 --- a/src/event-engine/core/handler.ts +++ b/src/event-engine/core/handler.ts @@ -25,7 +25,10 @@ class AsyncHandler extends Handler } start() { - this.asyncFunction(this.payload, this.abortSignal, this.dependencies); + this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch((error) => { + // console.log('Unhandled error:', error); + // swallow the error + }); } cancel() { diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index f76e416cb..f723ce2de 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -10,6 +10,9 @@ export type Dependencies = { getRetryDelay: (attempts: number) => number; shouldRetry: (error: Error, attempts: number) => boolean; delay: (milliseconds: number) => Promise; + + emitEvents: (events: any[]) => void; + emitStatus: (status: any) => void; }; export class EventEngineDispatcher extends Dispatcher { @@ -61,7 +64,7 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, abortSignal, { emitEvents }) => { if (payload.length > 0) { - console.log(payload); + emitEvents(payload); } }), ); + this.on( + effects.emitStatus.type, + asyncHandler(async (payload, abortSignal, { emitStatus }) => { + emitStatus(payload); + }), + ); + this.on( effects.reconnect.type, asyncHandler(async (payload, abortSignal, { receiveEvents, shouldRetry, getRetryDelay, delay }) => { @@ -132,7 +142,7 @@ export class EventEngineDispatcher extends Dispatcher events); -export const reconnect = createManagedEffect('RECONNECT', (context: ReceiveReconnectingStateContext) => context); +export const emitStatus = createEffect('EMIT_STATUS', (status: any) => status); + +export const reconnect = createManagedEffect( + 'RECEIVE_RECONNECT', + (context: ReceiveReconnectingStateContext) => context, +); export const handshakeReconnect = createManagedEffect( 'HANDSHAKE_RECONNECT', @@ -23,5 +28,10 @@ export const handshakeReconnect = createManagedEffect( ); export type Effects = MapOf< - typeof receiveEvents | typeof handshake | typeof emitEvents | typeof reconnect | typeof handshakeReconnect + | typeof receiveEvents + | typeof handshake + | typeof emitEvents + | typeof reconnect + | typeof handshakeReconnect + | typeof emitStatus >; diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 1ed3e1527..e5f2a8a7b 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -38,13 +38,13 @@ export const receivingSuccess = createEvent('RECEIVING_SUCCESS', (cursor: Cursor })); export const receivingFailure = createEvent('RECEIVING_FAILURE', (error: PubNubError) => error); -export const reconnectingSuccess = createEvent('RECONNECTING_SUCCESS', (cursor: Cursor, events: any[]) => ({ +export const reconnectingSuccess = createEvent('RECEIVING_RECONNECTING_SUCCESS', (cursor: Cursor, events: any[]) => ({ cursor, events, })); -export const reconnectingFailure = createEvent('RECONNECTING_FAILURE', (error: PubNubError) => error); -export const reconnectingGiveup = createEvent('RECONNECTING_GIVEUP', () => ({})); -export const reconnectingRetry = createEvent('RECONNECTING_RETRY', () => ({})); +export const reconnectingFailure = createEvent('RECEIVING_RECONNECTING_FAILURE', (error: PubNubError) => error); +export const reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', () => ({})); +export const reconnectingRetry = createEvent('RECEIVING_RECONNECTING_RETRY', () => ({})); export type Events = MapOf< | typeof subscriptionChange diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index c9a04e059..76cc28991 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -13,10 +13,12 @@ export class EventEngine { return this.engine; } + private _unsubscribeEngine!: () => void; + constructor(dependencies: Dependencies) { this.dispatcher = new EventEngineDispatcher(this.engine, dependencies); - this.engine.subscribe((change) => { + this._unsubscribeEngine = this.engine.subscribe((change) => { if (change.type === 'invocationDispatched') { this.dispatcher.dispatch(change.invocation); } @@ -56,4 +58,10 @@ export class EventEngine { disconnect() { this.engine.transition(events.disconnect()); } + + dispose() { + this.disconnect(); + this._unsubscribeEngine(); + this.dispatcher.dispose(); + } } diff --git a/src/event-engine/states/handshake_failure.ts b/src/event-engine/states/handshake_failure.ts index 7bc249a89..b1f956dd0 100644 --- a/src/event-engine/states/handshake_failure.ts +++ b/src/event-engine/states/handshake_failure.ts @@ -1,5 +1,5 @@ import { State } from '../core/state'; -import { Effects } from '../effects'; +import { Effects, emitStatus } from '../effects'; import { disconnect, Events, handshakingReconnectingRetry } from '../events'; import { PubNubError } from '../../core/components/endpoint'; import { HandshakeReconnectingState } from './handshake_reconnecting'; @@ -14,6 +14,8 @@ export type HandshakeFailureStateContext = { export const HandshakeFailureState = new State('HANDSHAKE_FAILURE'); +HandshakeFailureState.onEnter((context) => emitStatus({ category: 'PNNetworkIssuesCategory' })); + HandshakeFailureState.on(handshakingReconnectingRetry.type, (context) => HandshakeReconnectingState.with({ ...context, diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index 5ee6bc946..5dfac7f14 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -1,7 +1,13 @@ import { PubNubError } from '../../core/components/endpoint'; import { State } from '../core/state'; import { Effects, emitEvents, handshakeReconnect, reconnect } from '../effects'; -import { disconnect, Events, reconnectingFailure, reconnectingGiveup, reconnectingSuccess } from '../events'; +import { + disconnect, + Events, + handshakingReconnectingFailure, + handshakingReconnectingGiveup, + handshakingReconnectingSuccess, +} from '../events'; import { HandshakeFailureState } from './handshake_failure'; import { HandshakeStoppedState } from './handshake_stopped'; import { ReceivingState } from './receiving'; @@ -19,24 +25,21 @@ export const HandshakeReconnectingState = new State handshakeReconnect(context)); -HandshakeReconnectingState.onExit(() => reconnect.cancel); - -HandshakeReconnectingState.on(reconnectingSuccess.type, (context, event) => - ReceivingState.with( - { - channels: context.channels, - groups: context.groups, - cursor: event.payload.cursor, - }, - [emitEvents(event.payload.events)], - ), +HandshakeReconnectingState.onExit(() => handshakeReconnect.cancel); + +HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, (context, event) => + ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: event.payload.cursor, + }), ); -HandshakeReconnectingState.on(reconnectingFailure.type, (context, event) => +HandshakeReconnectingState.on(handshakingReconnectingFailure.type, (context, event) => HandshakeReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), ); -HandshakeReconnectingState.on(reconnectingGiveup.type, (context) => +HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, (context) => HandshakeFailureState.with({ groups: context.groups, channels: context.channels, diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index 864c5694b..4a779dc72 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -1,6 +1,6 @@ import { State } from '../core/state'; import { Cursor } from '../../models/Cursor'; -import { Effects, emitEvents, receiveEvents } from '../effects'; +import { Effects, emitEvents, emitStatus, receiveEvents } from '../effects'; import { disconnect, Events, receivingFailure, receivingSuccess, subscriptionChange } from '../events'; import { UnsubscribedState } from './unsubscribed'; import { ReceiveReconnectingState } from './receive_reconnecting'; @@ -15,6 +15,7 @@ export type ReceivingStateContext = { export const ReceivingState = new State('RECEIVING'); ReceivingState.onEnter((context) => receiveEvents(context.channels, context.groups, context.cursor)); +ReceivingState.onEnter((context) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onExit(() => receiveEvents.cancel); ReceivingState.on(receivingSuccess.type, (context, event) => { diff --git a/test/contract/definitions/event-engine.ts b/test/contract/definitions/event-engine.ts new file mode 100644 index 000000000..ce14c0e6e --- /dev/null +++ b/test/contract/definitions/event-engine.ts @@ -0,0 +1,118 @@ +import { after, binding, given, then, when } from 'cucumber-tsflow'; +import { DemoKeyset } from '../shared/keysets'; +import { PubNub, PubNubManager } from '../shared/pubnub'; +import type { MessageEvent, StatusEvent } from 'pubnub'; +import type { Change } from '../../../src/event-engine/core/change'; +import { DataTable } from '@cucumber/cucumber'; +import { expect } from 'chai'; + +function logChangelog(changelog: Change) { + switch (changelog.type) { + case 'engineStarted': + console.log(`START ${changelog.state.label}`); + return; + case 'transitionDone': + console.log(`${changelog.fromState.label} ===> ${changelog.toState.label}`); + return; + case 'invocationDispatched': + console.log( + `â—Š ${changelog.invocation.type} ${changelog.invocation.type === 'CANCEL' ? changelog.invocation.payload : ''}`, + ); + return; + case 'eventReceived': + console.log(`! ${changelog.event.type}`); + return; + } +} + +@binding([PubNubManager, DemoKeyset]) +class EventEngineSteps { + private pubnub?: PubNub; + + private messagePromise?: Promise; + private statusPromise?: Promise; + private changelog: Change[] = []; + + constructor(private manager: PubNubManager, private keyset: DemoKeyset) {} + + @given('the demo keyset with event engine enabled') + givenDemoKeyset() { + this.pubnub = this.manager.getInstance({ ...this.keyset, enableSubscribeBeta: true }); + + (this.pubnub as any).eventEngine._engine.subscribe((changelog: Change) => { + // logChangelog(changelog); + if (changelog.type === 'eventReceived' || changelog.type === 'invocationDispatched') { + this.changelog.push(changelog); + } + }); + } + + @given('a linear reconnection policy with {int} retries') + givenLinearReconnectionPolicy(retries: number) { + // TODO + } + + @when('I subscribe') + async whenISubscribe() { + this.statusPromise = new Promise((resolveStatus) => { + this.messagePromise = new Promise((resolveMessage) => { + this.pubnub?.addListener({ + message(messageEvent) { + resolveMessage(messageEvent); + }, + status(statusEvent) { + resolveStatus(statusEvent); + }, + }); + + this.pubnub?.subscribe({ channels: ['test'] }); + }); + }); + } + + @when('I publish a message') + async whenIPublishAMessage() { + const status = await this.statusPromise; + + expect(status?.category).to.equal('PNConnectedCategory'); + + const timetoken = await this.pubnub?.publish({ channel: 'test', message: { content: 'Hello world!' } }); + } + + @then('I receive an error') + async thenIReceiveError() { + const status = await this.statusPromise; + + expect(status?.category).to.equal('PNNetworkIssuesCategory'); + } + + @then('I receive the message in my subscribe response') + async receiveMessage() { + const message = await this.messagePromise; + } + + @then('I observe the following:') + thenIObserve(dataTable: DataTable) { + const expectedChangelog = dataTable.hashes(); + + const actualChangelog = []; + for (const entry of this.changelog) { + if (entry.type === 'eventReceived') { + actualChangelog.push({ type: 'event', name: entry.event.type }); + } else if (entry.type === 'invocationDispatched') { + actualChangelog.push({ + type: 'invocation', + name: `${entry.invocation.type}${entry.invocation.type === 'CANCEL' ? `_${entry.invocation.payload}` : ''}`, + }); + } + } + + expect(actualChangelog).to.deep.equal(expectedChangelog); + } + + @after() + dispose() { + (this.pubnub as any).removeAllListeners(); + (this.pubnub as any).eventEngine.dispose(); + } +} diff --git a/test/contract/definitions/grant.ts b/test/contract/definitions/grant.ts index 358284b24..dc4cf9365 100644 --- a/test/contract/definitions/grant.ts +++ b/test/contract/definitions/grant.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { binding, given, then, when } from 'cucumber-tsflow'; import { expect } from 'chai'; @@ -10,7 +11,7 @@ import { } from '../shared/fixtures'; import { ResourceType, AccessPermission } from '../shared/enums'; -import { ParsedGrantToken } from 'pubnub'; +import { ParsedGrantToken, GrantTokenParameters } from 'pubnub'; import { exists } from '../shared/helpers'; @binding([PubNubManager, AccessManagerKeyset]) @@ -20,8 +21,81 @@ class GrantTokenSteps { private token?: string; private parsedToken?: ParsedGrantToken; + private grantParams: Partial = {}; + + private resourceName?: string; + private resourceType?: ResourceType; + constructor(private manager: PubNubManager, private keyset: AccessManagerKeyset) {} + @given('the authorized UUID {string}') + public givenAuthorizedUUID(authorizedUUID: string) { + this.grantParams.authorized_uuid = authorizedUUID; + } + + @given('the TTL {int}') + public givenTTL(ttl: number) { + this.grantParams.ttl = ttl; + } + + @given('the {string} {resource_type} resource access permissions') + public givenResourceAccess(name: string, type: ResourceType) { + this.resourceType = type; + this.resourceName = name; + + this.grantParams.resources = { + ...(this.grantParams.resources ?? {}), + [type]: { + ...(this.grantParams.resources?.[type] ?? {}), + [name]: {}, + }, + }; + } + + @given('the {string} {resource_type} pattern access permissions') + public givenPatternAccess(name: string, type: ResourceType) { + this.resourceType = type; + this.resourceName = name; + + this.grantParams.patterns = { + ...(this.grantParams.patterns ?? {}), + [type]: { + ...(this.grantParams.patterns?.[type] ?? {}), + [name]: {}, + }, + }; + } + + @given('grant resource permission {access_permission}') + public givenGrantResourceAccessPermissions(permission: AccessPermission) { + exists(this.resourceType); + exists(this.resourceName); + + exists(this.grantParams.resources?.[this.resourceType]?.[this.resourceName]); + + this.grantParams.resources[this.resourceType]![this.resourceName][permission] = true; + } + + @given('deny resource permission {access_permission}') + public givenDenyResourceAccessPermissions(permission: AccessPermission) { + exists(this.resourceType); + exists(this.resourceName); + + exists(this.grantParams.resources?.[this.resourceType]?.[this.resourceName]); + + this.grantParams.resources[this.resourceType]![this.resourceName][permission] = false; + } + + @given('grant pattern permission {access_permission}') + public givenGrantPatternAccessPermissions(permission: AccessPermission) { + exists(this.resourceType); + exists(this.resourceName); + + exists(this.grantParams.patterns?.[this.resourceType]?.[this.resourceName]); + + this.grantParams.patterns[this.resourceType]![this.resourceName][permission] = true; + } + @given('I have a keyset with access manager enabled') public useAccessManagerKeyset(): void { this.pubnub = this.manager.getInstance(this.keyset); @@ -52,8 +126,19 @@ class GrantTokenSteps { expect(this.parsedToken).to.not.be.undefined; } - private resourceName?: string; - private resourceType?: ResourceType; + @when('I grant a token specifying those permissions') + public async grantToken() { + exists(this.grantParams); + + const params = this.grantParams as GrantTokenParameters; + + const token = await this.pubnub?.grantToken(params); + + exists(token); + + this.token = token; + this.parsedToken = this.pubnub?.parseToken(token); + } @then('the token has {string} {resource_type} pattern access permissions') public withPatternAccessPermissions(name: string, type: ResourceType) { @@ -65,12 +150,44 @@ class GrantTokenSteps { } @then('token pattern permission {access_permission}') - public hasAccessPermission(permission: AccessPermission) { + public hasPatternAccessPermission(permission: AccessPermission) { exists(this.resourceType); exists(this.resourceName); expect(this.parsedToken?.patterns?.[this.resourceType]?.[this.resourceName]?.[permission]).to.be.true; } + + @then('the token has {string} {resource_type} resource access permissions') + public withResourceAccessPermissions(name: string, type: ResourceType) { + this.resourceName = name; + this.resourceType = type; + + exists(this.parsedToken?.resources?.[type]); + exists(this.parsedToken?.resources?.[type]?.[name]); + } + + @then('token resource permission {access_permission}') + public hasResourceAccessPermission(permission: AccessPermission) { + exists(this.resourceType); + exists(this.resourceName); + + expect(this.parsedToken?.resources?.[this.resourceType]?.[this.resourceName]?.[permission]).to.be.true; + } + + @then('(the )token contains (the )TTL {int}') + public hasTTL(ttl: number) { + expect(this.parsedToken?.ttl).to.equal(ttl); + } + + @then('(the )token contains (the )authorized UUID {string}') + public hasAuthorizedUUID(authorizedUUID: string) { + expect(this.parsedToken?.authorized_uuid).to.equal(authorizedUUID); + } + + @then('the token does not contain an authorized uuid') + public doesntHaveAuthorizedUUID() { + expect(this.parsedToken?.authorized_uuid).to.be.undefined; + } } export = GrantTokenSteps; diff --git a/test/contract/setup.js b/test/contract/setup.js index 3280bec09..1ff1c68c8 100644 --- a/test/contract/setup.js +++ b/test/contract/setup.js @@ -1,11 +1,5 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ + require('ts-node').register({ - compilerOptions: { - module: 'commonjs', - resolveJsonModule: true, - moduleResolution: 'node', - experimentalDecorators: true, - target: 'es5', - sourceMap: true, - esModuleInterop: true, - }, + project: './test/contract/tsconfig.json', }); diff --git a/test/contract/shared/enums.ts b/test/contract/shared/enums.ts index 0c5695655..4819671e0 100644 --- a/test/contract/shared/enums.ts +++ b/test/contract/shared/enums.ts @@ -22,7 +22,7 @@ defineParameterType({ export enum ResourceType { channel = 'channels', - channelGroup = 'groups', + channel_group = 'groups', uuid = 'uuids', } diff --git a/test/contract/shared/hooks.ts b/test/contract/shared/hooks.ts new file mode 100644 index 000000000..fb76a61e2 --- /dev/null +++ b/test/contract/shared/hooks.ts @@ -0,0 +1,52 @@ +import { ITestCaseHookParameter } from '@cucumber/cucumber'; +import { binding, before, after } from 'cucumber-tsflow'; +import fetch from 'node-fetch'; +const CONTRACT_TAG_PREFIX = '@contract='; + +@binding([]) +class TomatoHooks { + contractServerUri = 'localhost:8090'; + isInitialized = false; + + contract?: string; + + @before() + async initializeContract(scenario: ITestCaseHookParameter) { + this.contract = this.getContract(scenario); + + if (this.contract) { + this.isInitialized = true; + + const response = await fetch(`http://${this.contractServerUri}/init?__contract__script__=${this.contract}`); + const result = await response.json(); + + if (result.ok !== true) { + throw new Error(`Something went wrong: ${result}`); + } + } + } + + @after() + async verifyContract() { + if (!this.isInitialized) { + return; + } + + const response = await fetch(`http://${this.contractServerUri}/expect`); + const result = await response.json(); + + if (result.expectations?.failed > 0) { + throw new Error(`The step failed due to contract server expectations. ${result.expectations}`); + } + } + + getContract(scenario: ITestCaseHookParameter) { + const tag = scenario.pickle.tags.find((tag) => tag.name.startsWith(CONTRACT_TAG_PREFIX)); + + if (tag) { + return tag.name.substring(CONTRACT_TAG_PREFIX.length); + } + } +} + +export = TomatoHooks; diff --git a/test/contract/shared/keysets.ts b/test/contract/shared/keysets.ts index 8943494cf..bcdbd5840 100644 --- a/test/contract/shared/keysets.ts +++ b/test/contract/shared/keysets.ts @@ -1,5 +1,12 @@ -export class AccessManagerKeyset { +import { Keyset } from './pubnub'; + +export class AccessManagerKeyset implements Keyset { publishKey = process.env.PUBLISH_KEY_ACCESS || 'pub-key'; subscribeKey = process.env.SUBSCRIBE_KEY_ACCESS || 'sub-key'; secretKey = process.env.SECRET_KEY_ACCESS || 'secret-key'; } + +export class DemoKeyset implements Keyset { + publishKey = 'demo'; + subscribeKey = 'demo'; +} diff --git a/test/contract/shared/pubnub.ts b/test/contract/shared/pubnub.ts index 21c23075e..0823e9d5a 100644 --- a/test/contract/shared/pubnub.ts +++ b/test/contract/shared/pubnub.ts @@ -12,6 +12,7 @@ export interface Config extends Keyset { suppressLeaveEvents?: boolean; logVerbosity?: boolean; uuid?: string; + enableSubscribeBeta?: boolean; } const defaultConfig: Config = { diff --git a/test/contract/tsconfig.json b/test/contract/tsconfig.json index cb5e89f26..88f3844ab 100644 --- a/test/contract/tsconfig.json +++ b/test/contract/tsconfig.json @@ -7,6 +7,9 @@ "target": "es5", "sourceMap": true, "esModuleInterop": true, - "strict": true - } + "strict": true, + "allowJs": true, + "noEmit": true + }, + "exclude": ["../../lib"] } From eb35e904f9a86c171037fef0e3571ce9c15800b5 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 19 May 2023 08:17:49 +0530 Subject: [PATCH 04/63] refactor event-engine(from draft PR) --- package-lock.json | 4 +-- src/core/pubnub-common.js | 16 +++++++++- src/event-engine/core/dispatcher.ts | 7 +++++ src/event-engine/core/handler.ts | 5 ++- src/event-engine/dispatcher.ts | 18 ++++++++--- src/event-engine/effects.ts | 14 +++++++-- src/event-engine/events.ts | 8 ++--- src/event-engine/index.ts | 10 +++++- src/event-engine/states/handshake_failure.ts | 4 ++- .../states/handshake_reconnecting.ts | 31 ++++++++++--------- src/event-engine/states/receiving.ts | 3 +- 11 files changed, 89 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7d977359..43c22dc25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pubnub", - "version": "7.2.0", + "version": "7.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pubnub", - "version": "7.2.0", + "version": "7.2.2", "license": "MIT", "dependencies": { "agentkeepalive": "^3.5.2", diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 89da7e91f..8b9bc6f1f 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -320,7 +320,21 @@ export default class { this.receiveMessages = endpointCreator.bind(this, modules, receiveMessagesConfig); if (config.enableSubscribeBeta === true) { - const eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages }); + const eventEngine = new EventEngine({ + handshake: this.handshake, + receiveEvents: this.receiveMessages, + getRetryDelay: (attempts) => attempts * 25, + delay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), + shouldRetry: (error, attempts) => attempts < 3, + emitEvents: (events) => { + for (const event of events) { + listenerManager.announceMessage(event); + } + }, + emitStatus: (status) => { + listenerManager.announceStatus(status); + }, + }); this.subscribe = eventEngine.subscribe.bind(eventEngine); this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); diff --git a/src/event-engine/core/dispatcher.ts b/src/event-engine/core/dispatcher.ts index c10bb5b46..598295d83 100644 --- a/src/event-engine/core/dispatcher.ts +++ b/src/event-engine/core/dispatcher.ts @@ -49,4 +49,11 @@ export class Dispatcher< instance.start(); } + + dispose() { + for (const [key, instance] of this.instances.entries()) { + instance.cancel(); + this.instances.delete(key); + } + } } diff --git a/src/event-engine/core/handler.ts b/src/event-engine/core/handler.ts index a419ea80f..041eba17b 100644 --- a/src/event-engine/core/handler.ts +++ b/src/event-engine/core/handler.ts @@ -25,7 +25,10 @@ class AsyncHandler extends Handler } start() { - this.asyncFunction(this.payload, this.abortSignal, this.dependencies); + this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch((error) => { + // console.log('Unhandled error:', error); + // swallow the error + }); } cancel() { diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index f76e416cb..f723ce2de 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -10,6 +10,9 @@ export type Dependencies = { getRetryDelay: (attempts: number) => number; shouldRetry: (error: Error, attempts: number) => boolean; delay: (milliseconds: number) => Promise; + + emitEvents: (events: any[]) => void; + emitStatus: (status: any) => void; }; export class EventEngineDispatcher extends Dispatcher { @@ -61,7 +64,7 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, abortSignal, { emitEvents }) => { if (payload.length > 0) { - console.log(payload); + emitEvents(payload); } }), ); + this.on( + effects.emitStatus.type, + asyncHandler(async (payload, abortSignal, { emitStatus }) => { + emitStatus(payload); + }), + ); + this.on( effects.reconnect.type, asyncHandler(async (payload, abortSignal, { receiveEvents, shouldRetry, getRetryDelay, delay }) => { @@ -132,7 +142,7 @@ export class EventEngineDispatcher extends Dispatcher events); -export const reconnect = createManagedEffect('RECONNECT', (context: ReceiveReconnectingStateContext) => context); +export const emitStatus = createEffect('EMIT_STATUS', (status: any) => status); + +export const reconnect = createManagedEffect( + 'RECEIVE_RECONNECT', + (context: ReceiveReconnectingStateContext) => context, +); export const handshakeReconnect = createManagedEffect( 'HANDSHAKE_RECONNECT', @@ -23,5 +28,10 @@ export const handshakeReconnect = createManagedEffect( ); export type Effects = MapOf< - typeof receiveEvents | typeof handshake | typeof emitEvents | typeof reconnect | typeof handshakeReconnect + | typeof receiveEvents + | typeof handshake + | typeof emitEvents + | typeof reconnect + | typeof handshakeReconnect + | typeof emitStatus >; diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 1ed3e1527..e5f2a8a7b 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -38,13 +38,13 @@ export const receivingSuccess = createEvent('RECEIVING_SUCCESS', (cursor: Cursor })); export const receivingFailure = createEvent('RECEIVING_FAILURE', (error: PubNubError) => error); -export const reconnectingSuccess = createEvent('RECONNECTING_SUCCESS', (cursor: Cursor, events: any[]) => ({ +export const reconnectingSuccess = createEvent('RECEIVING_RECONNECTING_SUCCESS', (cursor: Cursor, events: any[]) => ({ cursor, events, })); -export const reconnectingFailure = createEvent('RECONNECTING_FAILURE', (error: PubNubError) => error); -export const reconnectingGiveup = createEvent('RECONNECTING_GIVEUP', () => ({})); -export const reconnectingRetry = createEvent('RECONNECTING_RETRY', () => ({})); +export const reconnectingFailure = createEvent('RECEIVING_RECONNECTING_FAILURE', (error: PubNubError) => error); +export const reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', () => ({})); +export const reconnectingRetry = createEvent('RECEIVING_RECONNECTING_RETRY', () => ({})); export type Events = MapOf< | typeof subscriptionChange diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index c9a04e059..76cc28991 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -13,10 +13,12 @@ export class EventEngine { return this.engine; } + private _unsubscribeEngine!: () => void; + constructor(dependencies: Dependencies) { this.dispatcher = new EventEngineDispatcher(this.engine, dependencies); - this.engine.subscribe((change) => { + this._unsubscribeEngine = this.engine.subscribe((change) => { if (change.type === 'invocationDispatched') { this.dispatcher.dispatch(change.invocation); } @@ -56,4 +58,10 @@ export class EventEngine { disconnect() { this.engine.transition(events.disconnect()); } + + dispose() { + this.disconnect(); + this._unsubscribeEngine(); + this.dispatcher.dispose(); + } } diff --git a/src/event-engine/states/handshake_failure.ts b/src/event-engine/states/handshake_failure.ts index 7bc249a89..b1f956dd0 100644 --- a/src/event-engine/states/handshake_failure.ts +++ b/src/event-engine/states/handshake_failure.ts @@ -1,5 +1,5 @@ import { State } from '../core/state'; -import { Effects } from '../effects'; +import { Effects, emitStatus } from '../effects'; import { disconnect, Events, handshakingReconnectingRetry } from '../events'; import { PubNubError } from '../../core/components/endpoint'; import { HandshakeReconnectingState } from './handshake_reconnecting'; @@ -14,6 +14,8 @@ export type HandshakeFailureStateContext = { export const HandshakeFailureState = new State('HANDSHAKE_FAILURE'); +HandshakeFailureState.onEnter((context) => emitStatus({ category: 'PNNetworkIssuesCategory' })); + HandshakeFailureState.on(handshakingReconnectingRetry.type, (context) => HandshakeReconnectingState.with({ ...context, diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index 5ee6bc946..5dfac7f14 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -1,7 +1,13 @@ import { PubNubError } from '../../core/components/endpoint'; import { State } from '../core/state'; import { Effects, emitEvents, handshakeReconnect, reconnect } from '../effects'; -import { disconnect, Events, reconnectingFailure, reconnectingGiveup, reconnectingSuccess } from '../events'; +import { + disconnect, + Events, + handshakingReconnectingFailure, + handshakingReconnectingGiveup, + handshakingReconnectingSuccess, +} from '../events'; import { HandshakeFailureState } from './handshake_failure'; import { HandshakeStoppedState } from './handshake_stopped'; import { ReceivingState } from './receiving'; @@ -19,24 +25,21 @@ export const HandshakeReconnectingState = new State handshakeReconnect(context)); -HandshakeReconnectingState.onExit(() => reconnect.cancel); - -HandshakeReconnectingState.on(reconnectingSuccess.type, (context, event) => - ReceivingState.with( - { - channels: context.channels, - groups: context.groups, - cursor: event.payload.cursor, - }, - [emitEvents(event.payload.events)], - ), +HandshakeReconnectingState.onExit(() => handshakeReconnect.cancel); + +HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, (context, event) => + ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: event.payload.cursor, + }), ); -HandshakeReconnectingState.on(reconnectingFailure.type, (context, event) => +HandshakeReconnectingState.on(handshakingReconnectingFailure.type, (context, event) => HandshakeReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), ); -HandshakeReconnectingState.on(reconnectingGiveup.type, (context) => +HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, (context) => HandshakeFailureState.with({ groups: context.groups, channels: context.channels, diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index 864c5694b..4a779dc72 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -1,6 +1,6 @@ import { State } from '../core/state'; import { Cursor } from '../../models/Cursor'; -import { Effects, emitEvents, receiveEvents } from '../effects'; +import { Effects, emitEvents, emitStatus, receiveEvents } from '../effects'; import { disconnect, Events, receivingFailure, receivingSuccess, subscriptionChange } from '../events'; import { UnsubscribedState } from './unsubscribed'; import { ReceiveReconnectingState } from './receive_reconnecting'; @@ -15,6 +15,7 @@ export type ReceivingStateContext = { export const ReceivingState = new State('RECEIVING'); ReceivingState.onEnter((context) => receiveEvents(context.channels, context.groups, context.cursor)); +ReceivingState.onEnter((context) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onExit(() => receiveEvents.cancel); ReceivingState.on(receivingSuccess.type, (context, event) => { From f41d248b145f31e9d9bcd59219e7e03c1ebcd988 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 19 May 2023 09:12:00 +0530 Subject: [PATCH 05/63] event-engine: update to latest description, added some missing transitions --- src/event-engine/states/handshake_failure.ts | 5 ++++- .../states/handshake_reconnecting.ts | 6 ++++++ src/event-engine/states/receive_reconnecting.ts | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/event-engine/states/handshake_failure.ts b/src/event-engine/states/handshake_failure.ts index b1f956dd0..0f0fed581 100644 --- a/src/event-engine/states/handshake_failure.ts +++ b/src/event-engine/states/handshake_failure.ts @@ -1,9 +1,10 @@ import { State } from '../core/state'; import { Effects, emitStatus } from '../effects'; -import { disconnect, Events, handshakingReconnectingRetry } from '../events'; +import { disconnect, Events, handshakingReconnectingRetry, reconnect } from '../events'; import { PubNubError } from '../../core/components/endpoint'; import { HandshakeReconnectingState } from './handshake_reconnecting'; import { HandshakeStoppedState } from './handshake_stopped'; +import { HandshakingState } from './handshaking'; export type HandshakeFailureStateContext = { channels: string[]; @@ -29,3 +30,5 @@ HandshakeFailureState.on(disconnect.type, (context) => groups: context.groups, }), ); + +HandshakeFailureState.on(reconnect.type, (context) => HandshakingState.with({ ...context })); diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index 5dfac7f14..b6a426b09 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -7,9 +7,11 @@ import { handshakingReconnectingFailure, handshakingReconnectingGiveup, handshakingReconnectingSuccess, + subscriptionChange, } from '../events'; import { HandshakeFailureState } from './handshake_failure'; import { HandshakeStoppedState } from './handshake_stopped'; +import { HandshakingState } from './handshaking'; import { ReceivingState } from './receiving'; export type HandshakeReconnectingStateContext = { @@ -53,3 +55,7 @@ HandshakeReconnectingState.on(disconnect.type, (context) => groups: context.groups, }), ); + +HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => + HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), +); diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index dbf825922..a0f9ca37d 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -2,7 +2,7 @@ import { PubNubError } from '../../core/components/endpoint'; import { Cursor } from '../../models/Cursor'; import { State } from '../core/state'; import { Effects, emitEvents, reconnect } from '../effects'; -import { disconnect, Events, reconnectingFailure, reconnectingGiveup, reconnectingSuccess } from '../events'; +import { disconnect, Events, reconnectingFailure, reconnectingGiveup, reconnectingSuccess, restore, subscriptionChange } from '../events'; import { ReceivingState } from './receiving'; import { ReceiveFailureState } from './receive_failure'; import { ReceiveStoppedState } from './receive_stopped'; @@ -54,3 +54,18 @@ ReceiveReconnectingState.on(disconnect.type, (context) => cursor: context.cursor, }), ); + +ReceiveReconnectingState.on(restore.type, (context) => + ReceivingState.with({ + channels: context.channels, groups: context.groups, + cursor: context.cursor + }), +); + +ReceiveReconnectingState.on(subscriptionChange.type, (context, event) => + ReceivingState.with({ + channels: event.payload.channels, groups: event.payload.groups, + cursor: context.cursor + }), +); + From 6dd129448538e74c2d04b4fdc814bcd9f7eb5799 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 19 May 2023 09:59:39 +0530 Subject: [PATCH 06/63] prettier! --- .../states/receive_reconnecting.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index a0f9ca37d..eb3a3e7ba 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -2,7 +2,15 @@ import { PubNubError } from '../../core/components/endpoint'; import { Cursor } from '../../models/Cursor'; import { State } from '../core/state'; import { Effects, emitEvents, reconnect } from '../effects'; -import { disconnect, Events, reconnectingFailure, reconnectingGiveup, reconnectingSuccess, restore, subscriptionChange } from '../events'; +import { + disconnect, + Events, + reconnectingFailure, + reconnectingGiveup, + reconnectingSuccess, + restore, + subscriptionChange, +} from '../events'; import { ReceivingState } from './receiving'; import { ReceiveFailureState } from './receive_failure'; import { ReceiveStoppedState } from './receive_stopped'; @@ -57,15 +65,16 @@ ReceiveReconnectingState.on(disconnect.type, (context) => ReceiveReconnectingState.on(restore.type, (context) => ReceivingState.with({ - channels: context.channels, groups: context.groups, - cursor: context.cursor + channels: context.channels, + groups: context.groups, + cursor: context.cursor, }), ); ReceiveReconnectingState.on(subscriptionChange.type, (context, event) => ReceivingState.with({ - channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, }), ); - From ab2b56621c7066292819f31620e0e266ce2a5f1a Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Wed, 14 Jun 2023 19:22:28 +0530 Subject: [PATCH 07/63] take: fix hanging tests due to retry intro --- test/unit/event_engine.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/unit/event_engine.test.ts b/test/unit/event_engine.test.ts index db01a60c4..4568d0062 100644 --- a/test/unit/event_engine.test.ts +++ b/test/unit/event_engine.test.ts @@ -112,12 +112,13 @@ describe('EventEngine', () => { await forState('UNSUBSCRIBED', 1000); }); - it('should retry correctly', async () => { - utils.createNock().get('/v2/subscribe/demo/test/0').query(true).reply(200, '{"t":{"t":"12345","r":1}, "m": []}'); - utils.createNock().get('/v2/subscribe/demo/test/0').query(true).reply(500, '{"error": true}'); + // TODO: retry with configuration + // it('should retry correctly', async () => { + // utils.createNock().get('/v2/subscribe/demo/test/0').query(true).reply(200, '{"t":{"t":"12345","r":1}, "m": []}'); + // utils.createNock().get('/v2/subscribe/demo/test/0').query(true).reply(500, '{"error": true}'); - pubnub.subscribe({ channels: ['test'] }); + // pubnub.subscribe({ channels: ['test'] }); - await forState('RECEIVE_RECONNECTING', 1000); - }); + // await forState('RECEIVE_RECONNECTING', 1000); + // }); }); From 64d2371717802bcfdd43133efc71faf5e2b5612c Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 26 Jun 2023 22:56:18 +0530 Subject: [PATCH 08/63] update as per latest event engine specs --- src/core/constants/categories.js | 2 ++ src/event-engine/states/handshake_stopped.ts | 4 +-- .../states/receive_reconnecting.ts | 30 +++++++++++-------- src/event-engine/states/receive_stopped.ts | 2 +- src/event-engine/states/receiving.ts | 19 +++++++----- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/core/constants/categories.js b/src/core/constants/categories.js index 5c0cbb0e8..76809b824 100644 --- a/src/core/constants/categories.js +++ b/src/core/constants/categories.js @@ -27,4 +27,6 @@ export default { PNConnectedCategory: 'PNConnectedCategory', PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', + + PNDisconnectedCategory: 'PNDisconnectedCategory', }; diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index 71a061c61..483d214be 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -10,8 +10,8 @@ type HandshakeStoppedStateContext = { export const HandshakeStoppedState = new State('STOPPED'); -HandshakeStoppedState.on(subscriptionChange.type, (_context, event) => - HandshakeStoppedState.with({ +HandshakeStoppedState.on(subscriptionChange.type, (_, event) => + HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, }), diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index eb3a3e7ba..b5668f515 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -1,7 +1,7 @@ import { PubNubError } from '../../core/components/endpoint'; import { Cursor } from '../../models/Cursor'; import { State } from '../core/state'; -import { Effects, emitEvents, reconnect } from '../effects'; +import { Effects, emitEvents, reconnect, emitStatus } from '../effects'; import { disconnect, Events, @@ -47,20 +47,26 @@ ReceiveReconnectingState.on(reconnectingFailure.type, (context, event) => ); ReceiveReconnectingState.on(reconnectingGiveup.type, (context) => - ReceiveFailureState.with({ - groups: context.groups, - channels: context.channels, - cursor: context.cursor, - reason: context.reason, - }), + ReceiveFailureState.with( + { + groups: context.groups, + channels: context.channels, + cursor: context.cursor, + reason: context.reason, + }, + [emitStatus({ category: 'PNDisconnectedCategory' })], + ), ); ReceiveReconnectingState.on(disconnect.type, (context) => - ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }), + ReceiveStoppedState.with( + { + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }, + [emitStatus({ category: 'PNDisconnectedCategory' })], + ), ); ReceiveReconnectingState.on(restore.type, (context) => diff --git a/src/event-engine/states/receive_stopped.ts b/src/event-engine/states/receive_stopped.ts index 2b66a1337..6bca4abf9 100644 --- a/src/event-engine/states/receive_stopped.ts +++ b/src/event-engine/states/receive_stopped.ts @@ -13,7 +13,7 @@ type ReceiveStoppedStateContext = { export const ReceiveStoppedState = new State('STOPPED'); ReceiveStoppedState.on(subscriptionChange.type, (context, event) => - ReceiveStoppedState.with({ + ReceivingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: context.cursor, diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index 4a779dc72..604712026 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -15,7 +15,7 @@ export type ReceivingStateContext = { export const ReceivingState = new State('RECEIVING'); ReceivingState.onEnter((context) => receiveEvents(context.channels, context.groups, context.cursor)); -ReceivingState.onEnter((context) => emitStatus({ category: 'PNConnectedCategory' })); +ReceivingState.onEnter((_) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onExit(() => receiveEvents.cancel); ReceivingState.on(receivingSuccess.type, (context, event) => { @@ -38,10 +38,13 @@ ReceivingState.on(receivingFailure.type, (context, event) => { }); }); -ReceivingState.on(disconnect.type, (context) => - ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }), -); +ReceivingState.on(disconnect.type, (context) => { + return ReceiveStoppedState.with( + { + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }, + [emitStatus({ category: 'PNDisconnectedCategory' })], + ); +}); From 8afa24865327e1d069579c9384a584b71b2bddde Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 6 Jul 2023 12:21:01 +0530 Subject: [PATCH 09/63] * cucumber tsflow --- .pubnub.yml | 9 +- CHANGELOG.md | 6 + dist/web/pubnub.js | 144 ++++++--------- dist/web/pubnub.min.js | 4 +- lib/core/constants/categories.js | 1 + lib/core/constants/operations.js | 72 +------- lib/core/pubnub-common.js | 4 +- lib/event-engine/effects.js | 4 +- lib/event-engine/events.js | 14 +- lib/event-engine/states/handshake_failure.js | 2 + .../states/handshake_reconnecting.js | 4 + lib/event-engine/states/handshake_stopped.js | 4 +- .../states/receive_reconnecting.js | 16 +- lib/event-engine/states/receive_stopped.js | 2 +- lib/event-engine/states/receiving.js | 4 +- package.json | 4 +- src/core/components/_endpoint.ts | 24 --- src/core/constants/categories.js | 2 + src/core/constants/operations.ts | 164 ------------------ src/core/endpoints/user/create.ts | 40 ----- src/core/endpoints/user/fetch.ts | 32 ---- src/core/pubnub-common.js | 4 +- src/event-engine/effects.ts | 4 +- src/event-engine/events.ts | 17 +- src/event-engine/states/handshake_failure.ts | 5 +- .../states/handshake_reconnecting.ts | 7 + src/event-engine/states/handshake_stopped.ts | 4 +- .../states/receive_reconnecting.ts | 48 ++++- src/event-engine/states/receive_stopped.ts | 2 +- src/event-engine/states/receiving.ts | 19 +- test/contract/definitions/event-engine.ts | 2 +- 31 files changed, 190 insertions(+), 478 deletions(-) delete mode 100644 src/core/components/_endpoint.ts delete mode 100644 src/core/constants/operations.ts delete mode 100644 src/core/endpoints/user/create.ts delete mode 100644 src/core/endpoints/user/fetch.ts diff --git a/.pubnub.yml b/.pubnub.yml index 5de7e1211..219b058f7 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,10 @@ --- changelog: + - date: 2023-06-19 + version: v7.2.3 + changes: + - type: feature + text: "Added optional param `withHeartbeat` to set state through heartbeat endpoint." - date: 2022-12-12 version: v7.2.2 changes: @@ -886,7 +891,7 @@ sdks: - distribution-type: source distribution-repository: GitHub release package-name: pubnub.js - location: https://github.com/pubnub/javascript/archive/refs/tags/v7.2.2.zip + location: https://github.com/pubnub/javascript/archive/refs/tags/v7.2.3.zip requires: - name: 'agentkeepalive' min-version: '3.5.2' @@ -1557,7 +1562,7 @@ sdks: - distribution-type: library distribution-repository: GitHub release package-name: pubnub.js - location: https://github.com/pubnub/javascript/releases/download/v7.2.2/pubnub.7.2.2.js + location: https://github.com/pubnub/javascript/releases/download/v7.2.3/pubnub.7.2.3.js requires: - name: 'agentkeepalive' min-version: '3.5.2' diff --git a/CHANGELOG.md b/CHANGELOG.md index aae62931a..a2ef724ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v7.2.3 +June 19 2023 + +#### Added +- Added optional param `withHeartbeat` to set state through heartbeat endpoint. + ## v7.2.2 December 12 2022 diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index f9880d2dc..d46d5384a 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -1776,6 +1776,7 @@ PNReconnectedCategory: 'PNReconnectedCategory', PNConnectedCategory: 'PNConnectedCategory', PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', + PNDisconnectedCategory: 'PNDisconnectedCategory', }; var default_1$7 = /** @class */ (function () { @@ -2332,68 +2333,7 @@ return default_1; }()); - var Operation; - (function (Operation) { - Operation["Time"] = "PNTimeOperation"; - Operation["History"] = "PNHistoryOperation"; - Operation["DeleteMessages"] = "PNDeleteMessagesOperation"; - Operation["FetchMessages"] = "PNFetchMessagesOperation"; - Operation["MessageCounts"] = "PNMessageCountsOperation"; - Operation["Subscribe"] = "PNSubscribeOperation"; - Operation["Unsubscribe"] = "PNUnsubscribeOperation"; - Operation["Publish"] = "PNPublishOperation"; - Operation["Signal"] = "PNSignalOperation"; - Operation["AddMessageAction"] = "PNAddActionOperation"; - Operation["RemoveMessageAction"] = "PNRemoveMessageActionOperation"; - Operation["GetMessageActions"] = "PNGetMessageActionsOperation"; - Operation["CreateUser"] = "PNCreateUserOperation"; - Operation["UpdateUser"] = "PNUpdateUserOperation"; - Operation["RemoveUser"] = "PNRemoveUserOperation"; - Operation["FetchUser"] = "PNFetchUserOperation"; - Operation["GetUsers"] = "PNGetUsersOperation"; - Operation["CreateSpace"] = "PNCreateSpaceOperation"; - Operation["UpdateSpace"] = "PNUpdateSpaceOperation"; - Operation["RemoveSpace"] = "PNRemoveSpaceOperation"; - Operation["FetchSpace"] = "PNFetchSpaceOperation"; - Operation["GetSpaces"] = "PNGetSpacesOperation"; - Operation["GetMembers"] = "PNGetMembersOperation"; - Operation["UpdateMembers"] = "PNUpdateMembersOperation"; - Operation["GetMemberships"] = "PNGetMembershipsOperation"; - Operation["UpdateMemberships"] = "PNUpdateMembershipsOperation"; - Operation["ListFiles"] = "PNListFilesOperation"; - Operation["GenerateUploadUrl"] = "PNGenerateUploadUrlOperation"; - Operation["PublishFile"] = "PNPublishFileOperation"; - Operation["GetFileUrl"] = "PNGetFileUrlOperation"; - Operation["DownloadFile"] = "PNDownloadFileOperation"; - Operation["GetAllUUIDMetadata"] = "PNGetAllUUIDMetadataOperation"; - Operation["GetUUIDMetadata"] = "PNGetUUIDMetadataOperation"; - Operation["SetUUIDMetadata"] = "PNSetUUIDMetadataOperation"; - Operation["RemoveUUIDMetadata"] = "PNRemoveUUIDMetadataOperation"; - Operation["GetAllChannelMetadata"] = "PNGetAllChannelMetadataOperation"; - Operation["GetChannelMetadata"] = "PNGetChannelMetadataOperation"; - Operation["SetChannelMetadata"] = "PNSetChannelMetadataOperation"; - Operation["RemoveChannelMetadata"] = "PNRemoveChannelMetadataOperation"; - Operation["SetMembers"] = "PNSetMembersOperation"; - Operation["SetMemberships"] = "PNSetMembershipsOperation"; - Operation["PushNotificationEnabledChannels"] = "PNPushNotificationEnabledChannelsOperation"; - Operation["RemoveAllPushNotifications"] = "PNRemoveAllPushNotificationsOperation"; - Operation["WhereNow"] = "PNWhereNowOperation"; - Operation["SetState"] = "PNSetStateOperation"; - Operation["HereNow"] = "PNHereNowOperation"; - Operation["GetState"] = "PNGetStateOperation"; - Operation["Heartbeat"] = "PNHeartbeatOperation"; - Operation["ChannelGroups"] = "PNChannelGroupsOperation"; - Operation["RemoveGroup"] = "PNRemoveGroupOperation"; - Operation["ChannelsForGroup"] = "PNChannelsForGroupOperation"; - Operation["AddChannelsToGroup"] = "PNAddChannelsToGroupOperation"; - Operation["RemoveChannelsFromGroup"] = "PNRemoveChannelsFromGroupOperation"; - Operation["AccessManagerGrant"] = "PNAccessManagerGrant"; - Operation["AccessManagerGrantToken"] = "PNAccessManagerGrantToken"; - Operation["AccessManagerAudit"] = "PNAccessManagerAudit"; - Operation["AccessManagerRevokeToken"] = "PNAccessManagerRevokeToken"; - Operation["Handshake"] = "PNHandshakeOperation"; - Operation["ReceiveMessages"] = "PNReceiveMessagesOperation"; - })(Operation || (Operation = {})); + /* */ var OPERATIONS = { PNTimeOperation: 'PNTimeOperation', PNHistoryOperation: 'PNHistoryOperation', @@ -2412,13 +2352,13 @@ // Objects API PNCreateUserOperation: 'PNCreateUserOperation', PNUpdateUserOperation: 'PNUpdateUserOperation', - PNRemoveUserOperation: 'PNRemoveUserOperation', - PNFetchUserOperation: 'PNFetchUserOperation', + PNDeleteUserOperation: 'PNDeleteUserOperation', + PNGetUserOperation: 'PNGetUsersOperation', PNGetUsersOperation: 'PNGetUsersOperation', PNCreateSpaceOperation: 'PNCreateSpaceOperation', PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', - PNRemoveSpaceOperation: 'PNRemoveSpaceOperation', - PNFetchSpaceOperation: 'PNFetchSpaceOperation', + PNDeleteSpaceOperation: 'PNDeleteSpaceOperation', + PNGetSpaceOperation: 'PNGetSpacesOperation', PNGetSpacesOperation: 'PNGetSpacesOperation', PNGetMembersOperation: 'PNGetMembersOperation', PNUpdateMembersOperation: 'PNUpdateMembersOperation', @@ -7003,7 +6943,8 @@ return _this; } AsyncHandler.prototype.start = function () { - this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch(function () { + this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch(function (error) { + // console.log('Unhandled error:', error); // swallow the error }); }; @@ -7022,44 +6963,44 @@ channels: channels, groups: groups, }); }); - var receiveEvents = createManagedEffect('RECEIVE_EVENTS', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); - var emitEvents = createEffect('EMIT_EVENTS', function (events) { return events; }); + var receiveEvents = createManagedEffect('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); + var emitEvents = createEffect('EMIT_MESSAGES', function (events) { return events; }); var emitStatus = createEffect('EMIT_STATUS', function (status) { return status; }); - var reconnect$1 = createManagedEffect('RECONNECT', function (context) { return context; }); + var reconnect$1 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); - var subscriptionChange = createEvent('SUBSCRIPTION_CHANGE', function (channels, groups) { return ({ + var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups) { return ({ channels: channels, groups: groups, }); }); var disconnect = createEvent('DISCONNECT', function () { return ({}); }); var reconnect = createEvent('RECONNECT', function () { return ({}); }); - createEvent('RESTORE', function (channels, groups, timetoken, region) { return ({ + var restore = createEvent('RESTORE', function (channels, groups, timetoken, region) { return ({ channels: channels, groups: groups, timetoken: timetoken, region: region, }); }); - var handshakingSuccess = createEvent('HANDSHAKING_SUCCESS', function (cursor) { return cursor; }); - var handshakingFailure = createEvent('HANDSHAKING_FAILURE', function (error) { return error; }); + var handshakingSuccess = createEvent('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); + var handshakingFailure = createEvent('HANDSHAKE_FAILURE', function (error) { return error; }); var handshakingReconnectingSuccess = createEvent('HANDSHAKING_RECONNECTING_SUCCESS', function (cursor) { return ({ cursor: cursor, }); }); - var handshakingReconnectingFailure = createEvent('HANDSHAKING_RECONNECTING_FAILURE', function (error) { return error; }); + var handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); var handshakingReconnectingGiveup = createEvent('HANDSHAKING_RECONNECTING_GIVEUP', function () { return ({}); }); var handshakingReconnectingRetry = createEvent('HANDSHAKING_RECONNECTING_RETRY', function () { return ({}); }); - var receivingSuccess = createEvent('RECEIVING_SUCCESS', function (cursor, events) { return ({ + var receivingSuccess = createEvent('RECEIVE_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); - var receivingFailure = createEvent('RECEIVING_FAILURE', function (error) { return error; }); - var reconnectingSuccess = createEvent('RECONNECTING_SUCCESS', function (cursor, events) { return ({ + var receivingFailure = createEvent('RECEIVE_FAILURE', function (error) { return error; }); + var reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); - var reconnectingFailure = createEvent('RECONNECTING_FAILURE', function (error) { return error; }); - var reconnectingGiveup = createEvent('RECONNECTING_GIVEUP', function () { return ({}); }); - var reconnectingRetry = createEvent('RECONNECTING_RETRY', function () { return ({}); }); + var reconnectingFailure = createEvent('RECEIVING_RECONNECTING_FAILURE', function (error) { return error; }); + var reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); + var reconnectingRetry = createEvent('RECEIVING_RECONNECTING_RETRY', function () { return ({}); }); var EventEngineDispatcher = /** @class */ (function (_super) { __extends(EventEngineDispatcher, _super); @@ -7126,7 +7067,7 @@ if (error_1 instanceof Error && error_1.message === 'Aborted') { return [2 /*return*/]; } - if (error_1 instanceof PubNubError) { + if (error_1 instanceof PubNubError && !abortSignal.aborted) { return [2 /*return*/, engine.transition(receivingFailure(error_1))]; } return [3 /*break*/, 4]; @@ -7222,7 +7163,7 @@ })]; case 3: result = _b.sent(); - return [2 /*return*/, engine.transition(handshakingReconnectingSuccess(result.metadata))]; + return [2 /*return*/, engine.transition(handshakingReconnectingSuccess(result))]; case 4: error_3 = _b.sent(); if (error_3 instanceof Error && error_3.message === 'Aborted') { @@ -7243,8 +7184,8 @@ }(Dispatcher)); var HandshakeStoppedState = new State('STOPPED'); - HandshakeStoppedState.on(subscriptionChange.type, function (_context, event) { - return HandshakeStoppedState.with({ + HandshakeStoppedState.on(subscriptionChange.type, function (_, event) { + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, }); @@ -7252,6 +7193,7 @@ HandshakeStoppedState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); var HandshakeFailureState = new State('HANDSHAKE_FAILURE'); + HandshakeFailureState.onEnter(function (context) { return emitStatus({ category: 'PNNetworkIssuesCategory' }); }); HandshakeFailureState.on(handshakingReconnectingRetry.type, function (context) { return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); }); @@ -7261,10 +7203,11 @@ groups: context.groups, }); }); + HandshakeFailureState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); var ReceiveStoppedState = new State('STOPPED'); ReceiveStoppedState.on(subscriptionChange.type, function (context, event) { - return ReceiveStoppedState.with({ + return ReceivingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: context.cursor, @@ -7303,19 +7246,33 @@ channels: context.channels, cursor: context.cursor, reason: context.reason, - }); + }, [emitStatus({ category: 'PNDisconnectedCategory' })]); }); ReceiveReconnectingState.on(disconnect.type, function (context) { return ReceiveStoppedState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, + }, [emitStatus({ category: 'PNDisconnectedCategory' })]); + }); + ReceiveReconnectingState.on(restore.type, function (context) { + return ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }); + }); + ReceiveReconnectingState.on(subscriptionChange.type, function (context, event) { + return ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, }); }); var ReceivingState = new State('RECEIVING'); + ReceivingState.onEnter(function (_) { return emitStatus({ category: 'PNConnectedCategory' }); }); ReceivingState.onEnter(function (context) { return receiveEvents(context.channels, context.groups, context.cursor); }); - ReceivingState.onEnter(function (context) { return emitStatus({ category: 'PNConnectedCategory' }); }); ReceivingState.onExit(function () { return receiveEvents.cancel; }); ReceivingState.on(receivingSuccess.type, function (context, event) { return ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [emitEvents(event.payload.events)]); @@ -7334,12 +7291,12 @@ channels: context.channels, groups: context.groups, cursor: context.cursor, - }); + }, [emitStatus({ category: 'PNDisconnectedCategory' })]); }); var HandshakeReconnectingState = new State('HANDSHAKE_RECONNECTING'); HandshakeReconnectingState.onEnter(function (context) { return handshakeReconnect(context); }); - HandshakeReconnectingState.onExit(function () { return reconnect$1.cancel; }); + HandshakeReconnectingState.onExit(function () { return handshakeReconnect.cancel; }); HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, function (context, event) { return ReceivingState.with({ channels: context.channels, @@ -7363,6 +7320,9 @@ groups: context.groups, }); }); + HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + }); var HandshakingState = new State('HANDSHAKING'); HandshakingState.onEnter(function (context) { return handshake(context.channels, context.groups); }); @@ -7492,9 +7452,9 @@ var eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return attempts * 25; }, + getRetryDelay: function (attempts) { return attempts * 2; }, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (error, attempts) { return attempts < 3; }, + shouldRetry: function (error, attempts) { return attempts < 2; }, emitEvents: function (events) { var e_1, _a; try { diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 230f704eb..2d1a81bc4 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var v=function e(){var i,h,v=l(),b=v>>5,m=31&v;if(7===b)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(b<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(b))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var N;if(h<0)for(N=[];!f();)N.push(e());else for(N=new Array(h),i=0;i0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var v=function e(){var i,h,v=l(),b=v>>5,m=31&v;if(7===b)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(b<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(b))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var T;if(h<0)for(T=[];!f();)T.push(e());else for(T=new Array(h),i=0;i=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.2"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],k=s[1],T=s[2],N=s[3],u,7,c[0]),N=t(N,w,k,T,a,12,c[1]),T=t(T,N,w,k,l,17,c[2]),k=t(k,T,N,w,p,22,c[3]);w=t(w,k,T,N,h,7,c[4]),N=t(N,w,k,T,f,12,c[5]),T=t(T,N,w,k,d,17,c[6]),k=t(k,T,N,w,g,22,c[7]),w=t(w,k,T,N,y,7,c[8]),N=t(N,w,k,T,v,12,c[9]),T=t(T,N,w,k,b,17,c[10]),k=t(k,T,N,w,m,22,c[11]),w=t(w,k,T,N,_,7,c[12]),N=t(N,w,k,T,O,12,c[13]),T=t(T,N,w,k,P,17,c[14]),w=n(w,k=t(k,T,N,w,S,22,c[15]),T,N,a,5,c[16]),N=n(N,w,k,T,d,9,c[17]),T=n(T,N,w,k,m,14,c[18]),k=n(k,T,N,w,u,20,c[19]),w=n(w,k,T,N,f,5,c[20]),N=n(N,w,k,T,b,9,c[21]),T=n(T,N,w,k,S,14,c[22]),k=n(k,T,N,w,h,20,c[23]),w=n(w,k,T,N,v,5,c[24]),N=n(N,w,k,T,P,9,c[25]),T=n(T,N,w,k,p,14,c[26]),k=n(k,T,N,w,y,20,c[27]),w=n(w,k,T,N,O,5,c[28]),N=n(N,w,k,T,l,9,c[29]),T=n(T,N,w,k,g,14,c[30]),w=r(w,k=n(k,T,N,w,_,20,c[31]),T,N,f,4,c[32]),N=r(N,w,k,T,y,11,c[33]),T=r(T,N,w,k,m,16,c[34]),k=r(k,T,N,w,P,23,c[35]),w=r(w,k,T,N,a,4,c[36]),N=r(N,w,k,T,h,11,c[37]),T=r(T,N,w,k,g,16,c[38]),k=r(k,T,N,w,b,23,c[39]),w=r(w,k,T,N,O,4,c[40]),N=r(N,w,k,T,u,11,c[41]),T=r(T,N,w,k,p,16,c[42]),k=r(k,T,N,w,d,23,c[43]),w=r(w,k,T,N,v,4,c[44]),N=r(N,w,k,T,_,11,c[45]),T=r(T,N,w,k,S,16,c[46]),w=i(w,k=r(k,T,N,w,l,23,c[47]),T,N,u,6,c[48]),N=i(N,w,k,T,g,10,c[49]),T=i(T,N,w,k,P,15,c[50]),k=i(k,T,N,w,f,21,c[51]),w=i(w,k,T,N,_,6,c[52]),N=i(N,w,k,T,p,10,c[53]),T=i(T,N,w,k,b,15,c[54]),k=i(k,T,N,w,a,21,c[55]),w=i(w,k,T,N,y,6,c[56]),N=i(N,w,k,T,S,10,c[57]),T=i(T,N,w,k,d,15,c[58]),k=i(k,T,N,w,O,21,c[59]),w=i(w,k,T,N,h,6,c[60]),N=i(N,w,k,T,m,10,c[61]),T=i(T,N,w,k,l,15,c[62]),k=i(k,T,N,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+k|0,s[2]=s[2]+T|0,s[3]=s[3]+N|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function C(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function E(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A,M={signPamFromParams:function(e){return E(e).map((function(t){return"".concat(t,"=").concat(C(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:C},U={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},R=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new T({timeEndpoint:o}),this._dedupingManager=new k({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===U.PNTimeoutCategory?this._startSubscribeLoop():e.category===U.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:U.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===U.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=U.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=U.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(M.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}();!function(e){e.Time="PNTimeOperation",e.History="PNHistoryOperation",e.DeleteMessages="PNDeleteMessagesOperation",e.FetchMessages="PNFetchMessagesOperation",e.MessageCounts="PNMessageCountsOperation",e.Subscribe="PNSubscribeOperation",e.Unsubscribe="PNUnsubscribeOperation",e.Publish="PNPublishOperation",e.Signal="PNSignalOperation",e.AddMessageAction="PNAddActionOperation",e.RemoveMessageAction="PNRemoveMessageActionOperation",e.GetMessageActions="PNGetMessageActionsOperation",e.CreateUser="PNCreateUserOperation",e.UpdateUser="PNUpdateUserOperation",e.RemoveUser="PNRemoveUserOperation",e.FetchUser="PNFetchUserOperation",e.GetUsers="PNGetUsersOperation",e.CreateSpace="PNCreateSpaceOperation",e.UpdateSpace="PNUpdateSpaceOperation",e.RemoveSpace="PNRemoveSpaceOperation",e.FetchSpace="PNFetchSpaceOperation",e.GetSpaces="PNGetSpacesOperation",e.GetMembers="PNGetMembersOperation",e.UpdateMembers="PNUpdateMembersOperation",e.GetMemberships="PNGetMembershipsOperation",e.UpdateMemberships="PNUpdateMembershipsOperation",e.ListFiles="PNListFilesOperation",e.GenerateUploadUrl="PNGenerateUploadUrlOperation",e.PublishFile="PNPublishFileOperation",e.GetFileUrl="PNGetFileUrlOperation",e.DownloadFile="PNDownloadFileOperation",e.GetAllUUIDMetadata="PNGetAllUUIDMetadataOperation",e.GetUUIDMetadata="PNGetUUIDMetadataOperation",e.SetUUIDMetadata="PNSetUUIDMetadataOperation",e.RemoveUUIDMetadata="PNRemoveUUIDMetadataOperation",e.GetAllChannelMetadata="PNGetAllChannelMetadataOperation",e.GetChannelMetadata="PNGetChannelMetadataOperation",e.SetChannelMetadata="PNSetChannelMetadataOperation",e.RemoveChannelMetadata="PNRemoveChannelMetadataOperation",e.SetMembers="PNSetMembersOperation",e.SetMemberships="PNSetMembershipsOperation",e.PushNotificationEnabledChannels="PNPushNotificationEnabledChannelsOperation",e.RemoveAllPushNotifications="PNRemoveAllPushNotificationsOperation",e.WhereNow="PNWhereNowOperation",e.SetState="PNSetStateOperation",e.HereNow="PNHereNowOperation",e.GetState="PNGetStateOperation",e.Heartbeat="PNHeartbeatOperation",e.ChannelGroups="PNChannelGroupsOperation",e.RemoveGroup="PNRemoveGroupOperation",e.ChannelsForGroup="PNChannelsForGroupOperation",e.AddChannelsToGroup="PNAddChannelsToGroupOperation",e.RemoveChannelsFromGroup="PNRemoveChannelsFromGroupOperation",e.AccessManagerGrant="PNAccessManagerGrant",e.AccessManagerGrantToken="PNAccessManagerGrantToken",e.AccessManagerAudit="PNAccessManagerAudit",e.AccessManagerRevokeToken="PNAccessManagerRevokeToken",e.Handshake="PNHandshakeOperation",e.ReceiveMessages="PNReceiveMessagesOperation"}(A||(A={}));var j={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNRemoveUserOperation:"PNRemoveUserOperation",PNFetchUserOperation:"PNFetchUserOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNRemoveSpaceOperation:"PNRemoveSpaceOperation",PNFetchSpaceOperation:"PNFetchSpaceOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},x=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==j.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==j.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case j.PNPublishOperation:t="pub";break;case j.PNSignalOperation:t="sig";break;case j.PNHistoryOperation:case j.PNFetchMessagesOperation:case j.PNDeleteMessagesOperation:case j.PNMessageCounts:t="hist";break;case j.PNUnsubscribeOperation:case j.PNWhereNowOperation:case j.PNHereNowOperation:case j.PNHeartbeatOperation:case j.PNSetStateOperation:case j.PNGetStateOperation:t="pres";break;case j.PNAddChannelsToGroupOperation:case j.PNRemoveChannelsFromGroupOperation:case j.PNChannelGroupsOperation:case j.PNRemoveGroupOperation:case j.PNChannelsForGroupOperation:t="cg";break;case j.PNPushNotificationEnabledChannelsOperation:case j.PNRemoveAllPushNotificationsOperation:t="push";break;case j.PNCreateUserOperation:case j.PNUpdateUserOperation:case j.PNDeleteUserOperation:case j.PNGetUserOperation:case j.PNGetUsersOperation:case j.PNCreateSpaceOperation:case j.PNUpdateSpaceOperation:case j.PNDeleteSpaceOperation:case j.PNGetSpaceOperation:case j.PNGetSpacesOperation:case j.PNGetMembersOperation:case j.PNUpdateMembersOperation:case j.PNGetMembershipsOperation:case j.PNUpdateMembershipsOperation:t="obj";break;case j.PNAddMessageActionOperation:case j.PNRemoveMessageActionOperation:case j.PNGetMessageActionsOperation:t="msga";break;case j.PNAccessManagerGrant:case j.PNAccessManagerAudit:t="pam";break;case j.PNAccessManagerGrantToken:case j.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),I=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(I),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(I),F=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(I),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new D(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new F(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),L=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=U.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=U.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function q(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function z(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function V(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function W(e,t,n,r,i){var o=e.config,s=e.crypto,a=J(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(M.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function X(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return j.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(M.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return j.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return j.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(o),"/uuid/").concat(M.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var le=Object.freeze({__proto__:null,getOperation:function(){return j.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(M.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var pe=Object.freeze({__proto__:null,getOperation:function(){return j.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return j.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),de={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return j.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ye={getOperation:function(){return j.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(M.encodeString(t.channel),"/0/").concat(M.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,N,T,k,C,E,A,M,U,R,j,x,I,D,G,F,K,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",q("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",q("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(N=(w=l).POSTFILE,T=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,N.apply(w,T.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(C=(k=l).POSTFILE,E=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,C.apply(k,E.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,U=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,U.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(j=(R=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,j.apply(R,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(H=I.response,new Promise((function(e){var t="";H.on("data",(function(e){t+=e.toString("utf8")})),H.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);F=u.fileUploadPublishRetryLimit,K=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),K=!0,[3,26];case 25:return o.sent(),F-=1,[3,26];case 26:if(!K&&F>0)return[3,23];o.label=27;case 27:if(K)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var H}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",q("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",q("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",q("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(M.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=V(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&W(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},me={getOperation:function(){return j.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},_e={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},Oe={getOperation:function(){return j.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Pe={getOperation:function(){return j.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return j.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return j.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return j.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return j.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return j.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return j.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return j.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return j.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return j.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ue={getOperation:function(){return j.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Re=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var je=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function xe(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function Ie(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function De(e,t){if(xe(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=Ie(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=Ie(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=Ie(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=Ie(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=Ie(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=Ie(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=Ie(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=Ie(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=Ie(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=Ie(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=Ie(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=Ie(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var Ge=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrantToken},extractPermissions:Ie,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return xe(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return De(0,t)},handleResponse:function(e,t){return t.data.token}}),Fe={getOperation:function(){return j.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(M.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Le=Object.freeze({__proto__:null,getOperation:function(){return j.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(M.encodeString(r),"/0/").concat(M.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return j.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(M.encodeString(i),"/0/").concat(M.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var qe=Object.freeze({__proto__:null,getOperation:function(){return j.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(M.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return j.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(M.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return j.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(M.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Je=Object.freeze({__proto__:null,getOperation:function(){return j.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(M.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var We=Object.freeze({__proto__:null,getOperation:function(){return j.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var Xe=Object.freeze({__proto__:null,getOperation:function(){return j.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),$e={getOperation:function(){return j.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Qe={getOperation:function(){return j.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(ht.type,ut((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ft.type,ut((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Ct())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(Tt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(kt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(dt.type,ut((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r.metadata))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(tt),Mt=new Ze("STOPPED");Mt.on(gt.type,(function(e,t){return Mt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(vt.type,(function(e){return Gt.with(n({},e))}));var Ut=new Ze("HANDSHAKE_FAILURE");Ut.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),Ut.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Rt=new Ze("STOPPED");Rt.on(gt.type,(function(e,t){return Rt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(vt.type,(function(e){return It.with(n({},e))}));var jt=new Ze("RECEIVE_FAILURE");jt.on(Et.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),jt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ze("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ft(e)})),xt.onExit((function(){return ft.cancel})),xt.on(Tt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),xt.on(kt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Ct.type,(function(e){return jt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason})})),xt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onEnter((function(e){return ht({category:"PNConnectedCategory"})})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[pt(t.payload.events)])})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Ft.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Gt=new Ze("HANDSHAKING");Gt.onEnter((function(e){return ct(e.channels,e.groups)})),Gt.onExit((function(){return ct.cancel})),Gt.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Ft.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(yt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Ft=new Ze("UNSUBSCRIBED");Ft.on(gt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Kt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Ft,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(gt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(vt())},e.prototype.disconnect=function(){this.engine.transition(yt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new g({setup:e});this._config=o;var c=new N({config:o}),l=e.cryptography;r.init(o);var p=new H(o,i);this._tokenManager=p;var h=new x({maximumSamplesCount:6e4});this._telemetryManager=h;var f={config:o,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return l.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return l.decryptFile(e,n,t.File)};var d=X.bind(this,f,We),y=X.bind(this,f,oe),v=X.bind(this,f,ae),b=X.bind(this,f,ce),m=X.bind(this,f,Xe),_=new L;if(this._listenerManager=_,this.iAmHere=X.bind(this,f,ae),this.iAmAway=X.bind(this,f,oe),this.setPresenceState=X.bind(this,f,ce),this.handshake=X.bind(this,f,$e),this.receiveMessages=X.bind(this,f,Qe),!0===o.enableSubscribeBeta){var O=new Kt({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return 25*e},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return t<3},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;_.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){_.announceStatus(e)}});this.subscribe=O.subscribe.bind(O),this.unsubscribe=O.unsubscribe.bind(O),this.eventEngine=O}else{var P=new R({timeEndpoint:d,leaveEndpoint:y,heartbeatEndpoint:v,setStateEndpoint:b,subscribeEndpoint:m,crypto:f.crypto,config:f.config,listenerManager:_,getFileUrl:function(e){return be(f,e)}});this.subscribe=P.adaptSubscribeChange.bind(P),this.unsubscribe=P.adaptUnsubscribeChange.bind(P),this.disconnect=P.disconnect.bind(P),this.reconnect=P.reconnect.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.setState=P.adaptStateChange.bind(P),this.presence=P.adaptPresenceChange.bind(P),this.destroy=function(e){P.unsubscribeAll(e),P.disconnect()}}this.addListener=_.addListener.bind(_),this.removeListener=_.removeListener.bind(_),this.removeAllListeners=_.removeAllListeners.bind(_),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:X.bind(this,f,Z),listChannels:X.bind(this,f,ee),addChannels:X.bind(this,f,$),removeChannels:X.bind(this,f,Q),deleteGroup:X.bind(this,f,Y)},this.push={addChannels:X.bind(this,f,te),removeChannels:X.bind(this,f,ne),deleteDevice:X.bind(this,f,ie),listChannels:X.bind(this,f,re)},this.hereNow=X.bind(this,f,le),this.whereNow=X.bind(this,f,se),this.getState=X.bind(this,f,ue),this.grant=X.bind(this,f,je),this.grantToken=X.bind(this,f,Ge),this.audit=X.bind(this,f,Re),this.revokeToken=X.bind(this,f,Fe),this.publish=X.bind(this,f,Le),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=X.bind(this,f,He),this.history=X.bind(this,f,qe),this.deleteMessages=X.bind(this,f,ze),this.messageCounts=X.bind(this,f,Ve),this.fetchMessages=X.bind(this,f,Je),this.addMessageAction=X.bind(this,f,pe),this.removeMessageAction=X.bind(this,f,he),this.getMessageActions=X.bind(this,f,fe),this.listFiles=X.bind(this,f,de);var S=X.bind(this,f,ge);this.publishFile=X.bind(this,f,ye),this.sendFile=ve({generateUploadUrl:S,publishFile:this.publishFile,modules:f}),this.getFileUrl=function(e){return be(f,e)},this.downloadFile=X.bind(this,f,me),this.deleteFile=X.bind(this,f,_e),this.objects={getAllUUIDMetadata:X.bind(this,f,Oe),getUUIDMetadata:X.bind(this,f,Pe),setUUIDMetadata:X.bind(this,f,Se),removeUUIDMetadata:X.bind(this,f,we),getAllChannelMetadata:X.bind(this,f,Ne),getChannelMetadata:X.bind(this,f,Te),setChannelMetadata:X.bind(this,f,ke),removeChannelMetadata:X.bind(this,f,Ce),getChannelMembers:X.bind(this,f,Ee),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return U.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return U.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return U.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return U.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return U.PNNetworkIssuesCategory;if(e.timeout)return U.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return U.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return U.PNBadRequestCategory;if(e.response.forbidden)return U.PNAccessDeniedCategory}return U.PNUnknownCategory},e}();function Bt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?Bt(s):s})),n}var qt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),zt={exports:{}},Vt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function rn(e,t,n,r){void 0===r&&(r=Yt());var i,o=on(e,"",0,[],void 0,0,r)||e;try{i=0===Qt.length?JSON.stringify(o,t,n):JSON.stringify(o,sn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==$t.length;){var s=$t.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function on(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(fn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===pn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=dn[u]:u<2048?s+=dn[192|u>>6]+dn[128|63&u]:u<55296||u>=57344?s+=dn[224|u>>12]+dn[128|u>>6&63]+dn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=dn[240|u>>18]+dn[128|u>>12&63]+dn[128|u>>6&63]+dn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(fn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(On(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},xn=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&An.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},In={formats:ln,parse:function(e,t){var n=function(e){if(!e)return Un;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?Un.charset:e.charset;return{allowDots:void 0===e.allowDots?Un.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:Un.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:Un.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Un.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:Un.comma,decoder:"function"==typeof e.decoder?e.decoder:Un.decoder,delimiter:"string"==typeof e.delimiter||En.isRegExp(e.delimiter)?e.delimiter:Un.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:Un.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:Un.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:Un.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:Un.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Un.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Mn(l)?[l]:l),An.call(r,c)?r[c]=En.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Dn(e){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dn(e)}var Gn=function(e){return null!==e&&"object"===Dn(e)};function Fn(e){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fn(e)}var Kn=Gn,Ln=Hn;function Hn(e){if(e)return function(e){for(var t in Hn.prototype)Object.prototype.hasOwnProperty.call(Hn.prototype,t)&&(e[t]=Hn.prototype[t]);return e}(e)}Hn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Hn.prototype.parse=function(e){return this._parser=e,this},Hn.prototype.responseType=function(e){return this._responseType=e,this},Hn.prototype.serialize=function(e){return this._serializer=e,this},Hn.prototype.timeout=function(e){if(!e||"object"!==Fn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Hn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var Bn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),qn=new Set([408,413,429,500,502,503,504,521,522,524]);Hn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&qn.has(t.status))return!0;if(e){if(e.code&&Bn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Hn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Hn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Hn.prototype.catch=function(e){return this.then(void 0,e)},Hn.prototype.use=function(e){return e(this),this},Hn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Hn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Hn.prototype.get=function(e){return this._header[e.toLowerCase()]},Hn.prototype.getHeader=Hn.prototype.get,Hn.prototype.set=function(e,t){if(Kn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Hn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Hn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Kn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Hn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Hn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Hn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Hn.prototype.redirects=function(e){return this._maxRedirects=e,this},Hn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Hn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Hn.prototype.send=function(e){var t=Kn(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Kn(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Hn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Hn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Hn.prototype._appendQueryString=function(){console.warn("Unsupported")},Hn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Hn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var zn={};function Vn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(zt,zt.exports);var tr=zt.exports;function nr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function rr(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(nr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:U.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function ir(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=tr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function or(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function sr(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function ar(e,t,n,r){var i=tr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function ur(e,t,n,r){var i=tr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function cr(e,t,n){var r=tr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function lr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var pr,hr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=lr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=lr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),fr=(pr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),pr.supportsFile="undefined"!=typeof File,pr.supportsBlob="undefined"!=typeof Blob,pr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,pr.supportsBuffer=!1,pr.supportsStream=!1,pr.supportsString=!0,pr.supportsEncryptFile=!0,pr.supportsFileUri=!1,pr);function dr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var gr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:cr,get:sr,post:ar,patch:ur,sendBeacon:dr,getfile:or,postfile:ir}),t.cbor=new qt((function(e){return Bt(p.decode(e))}),y),t.PubNubFile=fr,t.cryptography=new hr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Lt);return gr})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 i(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=i,r.VERSION=t,e.uuid=r,e.isUUID=i}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var f=h.exports,d=function(){return f.uuid?f.uuid():f()},g=function(){function e(e){var t,n,r,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(d()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.setCipherKey(i.cipherKey),this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableSubscribeBeta=null!==(r=i.enableSubscribeBeta)&&void 0!==r&&r,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e){return this.cipherKey=e,this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.2"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],N=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,N,k,a,12,c[1]),k=t(k,T,w,N,l,17,c[2]),N=t(N,k,T,w,p,22,c[3]);w=t(w,N,k,T,h,7,c[4]),T=t(T,w,N,k,f,12,c[5]),k=t(k,T,w,N,d,17,c[6]),N=t(N,k,T,w,g,22,c[7]),w=t(w,N,k,T,y,7,c[8]),T=t(T,w,N,k,v,12,c[9]),k=t(k,T,w,N,b,17,c[10]),N=t(N,k,T,w,m,22,c[11]),w=t(w,N,k,T,_,7,c[12]),T=t(T,w,N,k,O,12,c[13]),k=t(k,T,w,N,P,17,c[14]),w=n(w,N=t(N,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,N,k,d,9,c[17]),k=n(k,T,w,N,m,14,c[18]),N=n(N,k,T,w,u,20,c[19]),w=n(w,N,k,T,f,5,c[20]),T=n(T,w,N,k,b,9,c[21]),k=n(k,T,w,N,S,14,c[22]),N=n(N,k,T,w,h,20,c[23]),w=n(w,N,k,T,v,5,c[24]),T=n(T,w,N,k,P,9,c[25]),k=n(k,T,w,N,p,14,c[26]),N=n(N,k,T,w,y,20,c[27]),w=n(w,N,k,T,O,5,c[28]),T=n(T,w,N,k,l,9,c[29]),k=n(k,T,w,N,g,14,c[30]),w=r(w,N=n(N,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,N,k,y,11,c[33]),k=r(k,T,w,N,m,16,c[34]),N=r(N,k,T,w,P,23,c[35]),w=r(w,N,k,T,a,4,c[36]),T=r(T,w,N,k,h,11,c[37]),k=r(k,T,w,N,g,16,c[38]),N=r(N,k,T,w,b,23,c[39]),w=r(w,N,k,T,O,4,c[40]),T=r(T,w,N,k,u,11,c[41]),k=r(k,T,w,N,p,16,c[42]),N=r(N,k,T,w,d,23,c[43]),w=r(w,N,k,T,v,4,c[44]),T=r(T,w,N,k,_,11,c[45]),k=r(k,T,w,N,S,16,c[46]),w=i(w,N=r(N,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,N,k,g,10,c[49]),k=i(k,T,w,N,P,15,c[50]),N=i(N,k,T,w,f,21,c[51]),w=i(w,N,k,T,_,6,c[52]),T=i(T,w,N,k,p,10,c[53]),k=i(k,T,w,N,b,15,c[54]),N=i(N,k,T,w,a,21,c[55]),w=i(w,N,k,T,y,6,c[56]),T=i(T,w,N,k,S,10,c[57]),k=i(k,T,w,N,d,15,c[58]),N=i(N,k,T,w,O,21,c[59]),w=i(w,N,k,T,h,6,c[60]),T=i(T,w,N,k,m,10,c[61]),k=i(k,T,w,N,l,15,c[62]),N=i(N,k,T,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+N|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function E(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function C(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return C(e).map((function(t){return"".concat(t,"=").concat(E(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:E},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory"},j=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new N({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),R={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==R.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==R.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case R.PNPublishOperation:t="pub";break;case R.PNSignalOperation:t="sig";break;case R.PNHistoryOperation:case R.PNFetchMessagesOperation:case R.PNDeleteMessagesOperation:case R.PNMessageCounts:t="hist";break;case R.PNUnsubscribeOperation:case R.PNWhereNowOperation:case R.PNHereNowOperation:case R.PNHeartbeatOperation:case R.PNSetStateOperation:case R.PNGetStateOperation:t="pres";break;case R.PNAddChannelsToGroupOperation:case R.PNRemoveChannelsFromGroupOperation:case R.PNChannelGroupsOperation:case R.PNRemoveGroupOperation:case R.PNChannelsForGroupOperation:t="cg";break;case R.PNPushNotificationEnabledChannelsOperation:case R.PNRemoveAllPushNotificationsOperation:t="push";break;case R.PNCreateUserOperation:case R.PNUpdateUserOperation:case R.PNDeleteUserOperation:case R.PNGetUserOperation:case R.PNGetUsersOperation:case R.PNCreateSpaceOperation:case R.PNUpdateSpaceOperation:case R.PNDeleteSpaceOperation:case R.PNGetSpaceOperation:case R.PNGetSpacesOperation:case R.PNGetMembersOperation:case R.PNUpdateMembersOperation:case R.PNGetMembershipsOperation:case R.PNUpdateMembershipsOperation:t="obj";break;case R.PNAddMessageActionOperation:case R.PNRemoveMessageActionOperation:case R.PNGetMessageActionsOperation:t="msga";break;case R.PNAccessManagerGrant:case R.PNAccessManagerAudit:t="pam";break;case R.PNAccessManagerGrantToken:case R.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function W(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return R.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return R.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return R.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return R.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return R.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return R.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return R.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return R.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,T,k,N,E,C,A,M,j,R,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(E=(N=l).POSTFILE,C=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,E.apply(N,C.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,j=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,j.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(R=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(R,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},be={getOperation:function(){return R.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return R.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return R.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return R.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return R.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return R.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return R.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return R.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return R.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return R.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ce={getOperation:function(){return R.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return R.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return R.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var je=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var Re=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return R.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return R.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return R.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return R.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return R.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return R.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return R.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return R.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var We=Object.freeze({__proto__:null,getOperation:function(){return R.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Xe={getOperation:function(){return R.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return R.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(pt.type,at((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ht.type,at((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Et())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Nt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(ft.type,at((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(yt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("HANDSHAKE_FAILURE");jt.onEnter((function(e){return pt({category:"PNNetworkIssuesCategory"})})),jt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),jt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),jt.on(yt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ye("STOPPED");Rt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(yt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Ct.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(gt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ht(e)})),xt.onExit((function(){return ht.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),xt.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Et.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[pt({category:"PNDisconnectedCategory"})])})),xt.on(gt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])})),xt.on(vt.type,(function(e){return It.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt({category:"PNConnectedCategory"})})),It.onEnter((function(e){return ct(e.channels,e.groups,e.cursor)})),It.onExit((function(){return ct.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[lt(t.payload.events)])})),It.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(gt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ft(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return jt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Dt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return ut(e.channels,e.groups)})),Gt.onExit((function(){return ut.cancel})),Gt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(dt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(yt())},e.prototype.disconnect=function(){this.engine.transition(gt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new g({setup:e});this._config=o;var c=new T({config:o}),l=e.cryptography;r.init(o);var p=new L(o,i);this._tokenManager=p;var h=new U({maximumSamplesCount:6e4});this._telemetryManager=h;var f={config:o,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return l.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return l.decryptFile(e,n,t.File)};var d=W.bind(this,f,Je),y=W.bind(this,f,ie),v=W.bind(this,f,se),b=W.bind(this,f,ue),m=W.bind(this,f,We),_=new F;if(this._listenerManager=_,this.iAmHere=W.bind(this,f,se),this.iAmAway=W.bind(this,f,ie),this.setPresenceState=W.bind(this,f,ue),this.handshake=W.bind(this,f,Xe),this.receiveMessages=W.bind(this,f,$e),!0===o.enableSubscribeBeta){var O=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return 2*e},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return t<2},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;_.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){_.announceStatus(e)}});this.subscribe=O.subscribe.bind(O),this.unsubscribe=O.unsubscribe.bind(O),this.eventEngine=O}else{var P=new j({timeEndpoint:d,leaveEndpoint:y,heartbeatEndpoint:v,setStateEndpoint:b,subscribeEndpoint:m,crypto:f.crypto,config:f.config,listenerManager:_,getFileUrl:function(e){return ve(f,e)}});this.subscribe=P.adaptSubscribeChange.bind(P),this.unsubscribe=P.adaptUnsubscribeChange.bind(P),this.disconnect=P.disconnect.bind(P),this.reconnect=P.reconnect.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.setState=P.adaptStateChange.bind(P),this.presence=P.adaptPresenceChange.bind(P),this.destroy=function(e){P.unsubscribeAll(e),P.disconnect()}}this.addListener=_.addListener.bind(_),this.removeListener=_.removeListener.bind(_),this.removeAllListeners=_.removeAllListeners.bind(_),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:W.bind(this,f,Y),listChannels:W.bind(this,f,Z),addChannels:W.bind(this,f,X),removeChannels:W.bind(this,f,$),deleteGroup:W.bind(this,f,Q)},this.push={addChannels:W.bind(this,f,ee),removeChannels:W.bind(this,f,te),deleteDevice:W.bind(this,f,re),listChannels:W.bind(this,f,ne)},this.hereNow=W.bind(this,f,ce),this.whereNow=W.bind(this,f,oe),this.getState=W.bind(this,f,ae),this.grant=W.bind(this,f,Re),this.grantToken=W.bind(this,f,De),this.audit=W.bind(this,f,je),this.revokeToken=W.bind(this,f,Ge),this.publish=W.bind(this,f,Fe),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=W.bind(this,f,Le),this.history=W.bind(this,f,He),this.deleteMessages=W.bind(this,f,qe),this.messageCounts=W.bind(this,f,ze),this.fetchMessages=W.bind(this,f,Ve),this.addMessageAction=W.bind(this,f,le),this.removeMessageAction=W.bind(this,f,pe),this.getMessageActions=W.bind(this,f,he),this.listFiles=W.bind(this,f,fe);var S=W.bind(this,f,de);this.publishFile=W.bind(this,f,ge),this.sendFile=ye({generateUploadUrl:S,publishFile:this.publishFile,modules:f}),this.getFileUrl=function(e){return ve(f,e)},this.downloadFile=W.bind(this,f,be),this.deleteFile=W.bind(this,f,me),this.objects={getAllUUIDMetadata:W.bind(this,f,_e),getUUIDMetadata:W.bind(this,f,Oe),setUUIDMetadata:W.bind(this,f,Pe),removeUUIDMetadata:W.bind(this,f,Se),getAllChannelMetadata:W.bind(this,f,we),getChannelMetadata:W.bind(this,f,Te),setChannelMetadata:W.bind(this,f,ke),removeChannelMetadata:W.bind(this,f,Ne),getChannelMembers:W.bind(this,f,Ee),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function Ht(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?Ht(s):s})),n}var qt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),zt={exports:{}},Vt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function rn(e,t,n,r){void 0===r&&(r=Yt());var i,o=on(e,"",0,[],void 0,0,r)||e;try{i=0===Qt.length?JSON.stringify(o,t,n):JSON.stringify(o,sn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==$t.length;){var s=$t.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function on(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(fn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===pn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=dn[u]:u<2048?s+=dn[192|u>>6]+dn[128|63&u]:u<55296||u>=57344?s+=dn[224|u>>12]+dn[128|u>>6&63]+dn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=dn[240|u>>18]+dn[128|u>>12&63]+dn[128|u>>6&63]+dn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(fn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(On(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},xn=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&An.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},In={formats:ln,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||Cn.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Mn(l)?[l]:l),An.call(r,c)?r[c]=Cn.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Dn(e){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dn(e)}var Gn=function(e){return null!==e&&"object"===Dn(e)};function Kn(e){return Kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kn(e)}var Fn=Gn,Ln=Bn;function Bn(e){if(e)return function(e){for(var t in Bn.prototype)Object.prototype.hasOwnProperty.call(Bn.prototype,t)&&(e[t]=Bn.prototype[t]);return e}(e)}Bn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Bn.prototype.parse=function(e){return this._parser=e,this},Bn.prototype.responseType=function(e){return this._responseType=e,this},Bn.prototype.serialize=function(e){return this._serializer=e,this},Bn.prototype.timeout=function(e){if(!e||"object"!==Kn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Bn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var Hn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),qn=new Set([408,413,429,500,502,503,504,521,522,524]);Bn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&qn.has(t.status))return!0;if(e){if(e.code&&Hn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Bn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Bn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Bn.prototype.catch=function(e){return this.then(void 0,e)},Bn.prototype.use=function(e){return e(this),this},Bn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Bn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Bn.prototype.get=function(e){return this._header[e.toLowerCase()]},Bn.prototype.getHeader=Bn.prototype.get,Bn.prototype.set=function(e,t){if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Bn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Bn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Bn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Bn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Bn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Bn.prototype.redirects=function(e){return this._maxRedirects=e,this},Bn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Bn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Bn.prototype.send=function(e){var t=Fn(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Fn(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Bn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Bn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Bn.prototype._appendQueryString=function(){console.warn("Unsupported")},Bn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Bn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var zn={};function Vn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(zt,zt.exports);var tr=zt.exports;function nr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function rr(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(nr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function ir(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=tr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function or(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function sr(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function ar(e,t,n,r){var i=tr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function ur(e,t,n,r){var i=tr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function cr(e,t,n){var r=tr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function lr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var pr,hr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=lr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=lr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),fr=(pr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),pr.supportsFile="undefined"!=typeof File,pr.supportsBlob="undefined"!=typeof Blob,pr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,pr.supportsBuffer=!1,pr.supportsStream=!1,pr.supportsString=!0,pr.supportsEncryptFile=!0,pr.supportsFileUri=!1,pr);function dr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var gr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Bt({del:cr,get:sr,post:ar,patch:ur,sendBeacon:dr,getfile:or,postfile:ir}),t.cbor=new qt((function(e){return Ht(p.decode(e))}),y),t.PubNubFile=fr,t.cryptography=new hr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Lt);return gr})); diff --git a/lib/core/constants/categories.js b/lib/core/constants/categories.js index 34f55dbc3..73970bf60 100644 --- a/lib/core/constants/categories.js +++ b/lib/core/constants/categories.js @@ -20,4 +20,5 @@ exports.default = { PNReconnectedCategory: 'PNReconnectedCategory', PNConnectedCategory: 'PNConnectedCategory', PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', + PNDisconnectedCategory: 'PNDisconnectedCategory', }; diff --git a/lib/core/constants/operations.js b/lib/core/constants/operations.js index 8dad48b82..5a934e464 100644 --- a/lib/core/constants/operations.js +++ b/lib/core/constants/operations.js @@ -1,68 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Operation = void 0; -var Operation; -(function (Operation) { - Operation["Time"] = "PNTimeOperation"; - Operation["History"] = "PNHistoryOperation"; - Operation["DeleteMessages"] = "PNDeleteMessagesOperation"; - Operation["FetchMessages"] = "PNFetchMessagesOperation"; - Operation["MessageCounts"] = "PNMessageCountsOperation"; - Operation["Subscribe"] = "PNSubscribeOperation"; - Operation["Unsubscribe"] = "PNUnsubscribeOperation"; - Operation["Publish"] = "PNPublishOperation"; - Operation["Signal"] = "PNSignalOperation"; - Operation["AddMessageAction"] = "PNAddActionOperation"; - Operation["RemoveMessageAction"] = "PNRemoveMessageActionOperation"; - Operation["GetMessageActions"] = "PNGetMessageActionsOperation"; - Operation["CreateUser"] = "PNCreateUserOperation"; - Operation["UpdateUser"] = "PNUpdateUserOperation"; - Operation["RemoveUser"] = "PNRemoveUserOperation"; - Operation["FetchUser"] = "PNFetchUserOperation"; - Operation["GetUsers"] = "PNGetUsersOperation"; - Operation["CreateSpace"] = "PNCreateSpaceOperation"; - Operation["UpdateSpace"] = "PNUpdateSpaceOperation"; - Operation["RemoveSpace"] = "PNRemoveSpaceOperation"; - Operation["FetchSpace"] = "PNFetchSpaceOperation"; - Operation["GetSpaces"] = "PNGetSpacesOperation"; - Operation["GetMembers"] = "PNGetMembersOperation"; - Operation["UpdateMembers"] = "PNUpdateMembersOperation"; - Operation["GetMemberships"] = "PNGetMembershipsOperation"; - Operation["UpdateMemberships"] = "PNUpdateMembershipsOperation"; - Operation["ListFiles"] = "PNListFilesOperation"; - Operation["GenerateUploadUrl"] = "PNGenerateUploadUrlOperation"; - Operation["PublishFile"] = "PNPublishFileOperation"; - Operation["GetFileUrl"] = "PNGetFileUrlOperation"; - Operation["DownloadFile"] = "PNDownloadFileOperation"; - Operation["GetAllUUIDMetadata"] = "PNGetAllUUIDMetadataOperation"; - Operation["GetUUIDMetadata"] = "PNGetUUIDMetadataOperation"; - Operation["SetUUIDMetadata"] = "PNSetUUIDMetadataOperation"; - Operation["RemoveUUIDMetadata"] = "PNRemoveUUIDMetadataOperation"; - Operation["GetAllChannelMetadata"] = "PNGetAllChannelMetadataOperation"; - Operation["GetChannelMetadata"] = "PNGetChannelMetadataOperation"; - Operation["SetChannelMetadata"] = "PNSetChannelMetadataOperation"; - Operation["RemoveChannelMetadata"] = "PNRemoveChannelMetadataOperation"; - Operation["SetMembers"] = "PNSetMembersOperation"; - Operation["SetMemberships"] = "PNSetMembershipsOperation"; - Operation["PushNotificationEnabledChannels"] = "PNPushNotificationEnabledChannelsOperation"; - Operation["RemoveAllPushNotifications"] = "PNRemoveAllPushNotificationsOperation"; - Operation["WhereNow"] = "PNWhereNowOperation"; - Operation["SetState"] = "PNSetStateOperation"; - Operation["HereNow"] = "PNHereNowOperation"; - Operation["GetState"] = "PNGetStateOperation"; - Operation["Heartbeat"] = "PNHeartbeatOperation"; - Operation["ChannelGroups"] = "PNChannelGroupsOperation"; - Operation["RemoveGroup"] = "PNRemoveGroupOperation"; - Operation["ChannelsForGroup"] = "PNChannelsForGroupOperation"; - Operation["AddChannelsToGroup"] = "PNAddChannelsToGroupOperation"; - Operation["RemoveChannelsFromGroup"] = "PNRemoveChannelsFromGroupOperation"; - Operation["AccessManagerGrant"] = "PNAccessManagerGrant"; - Operation["AccessManagerGrantToken"] = "PNAccessManagerGrantToken"; - Operation["AccessManagerAudit"] = "PNAccessManagerAudit"; - Operation["AccessManagerRevokeToken"] = "PNAccessManagerRevokeToken"; - Operation["Handshake"] = "PNHandshakeOperation"; - Operation["ReceiveMessages"] = "PNReceiveMessagesOperation"; -})(Operation = exports.Operation || (exports.Operation = {})); +/* */ exports.default = { PNTimeOperation: 'PNTimeOperation', PNHistoryOperation: 'PNHistoryOperation', @@ -81,13 +19,13 @@ exports.default = { // Objects API PNCreateUserOperation: 'PNCreateUserOperation', PNUpdateUserOperation: 'PNUpdateUserOperation', - PNRemoveUserOperation: 'PNRemoveUserOperation', - PNFetchUserOperation: 'PNFetchUserOperation', + PNDeleteUserOperation: 'PNDeleteUserOperation', + PNGetUserOperation: 'PNGetUsersOperation', PNGetUsersOperation: 'PNGetUsersOperation', PNCreateSpaceOperation: 'PNCreateSpaceOperation', PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', - PNRemoveSpaceOperation: 'PNRemoveSpaceOperation', - PNFetchSpaceOperation: 'PNFetchSpaceOperation', + PNDeleteSpaceOperation: 'PNDeleteSpaceOperation', + PNGetSpaceOperation: 'PNGetSpacesOperation', PNGetSpacesOperation: 'PNGetSpacesOperation', PNGetMembersOperation: 'PNGetMembersOperation', PNUpdateMembersOperation: 'PNUpdateMembersOperation', diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index 253e1ab10..a2b579ac4 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -185,9 +185,9 @@ var default_1 = /** @class */ (function () { var eventEngine = new event_engine_1.EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return attempts * 25; }, + getRetryDelay: function (attempts) { return attempts * 2; }, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (error, attempts) { return attempts < 3; }, + shouldRetry: function (error, attempts) { return attempts < 2; }, emitEvents: function (events) { var e_1, _a; try { diff --git a/lib/event-engine/effects.js b/lib/event-engine/effects.js index 02875a14b..b9d1ea250 100644 --- a/lib/event-engine/effects.js +++ b/lib/event-engine/effects.js @@ -6,8 +6,8 @@ exports.handshake = (0, core_1.createManagedEffect)('HANDSHAKE', function (chann channels: channels, groups: groups, }); }); -exports.receiveEvents = (0, core_1.createManagedEffect)('RECEIVE_EVENTS', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); -exports.emitEvents = (0, core_1.createEffect)('EMIT_EVENTS', function (events) { return events; }); +exports.receiveEvents = (0, core_1.createManagedEffect)('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); +exports.emitEvents = (0, core_1.createEffect)('EMIT_MESSAGES', function (events) { return events; }); exports.emitStatus = (0, core_1.createEffect)('EMIT_STATUS', function (status) { return status; }); exports.reconnect = (0, core_1.createManagedEffect)('RECEIVE_RECONNECT', function (context) { return context; }); exports.handshakeReconnect = (0, core_1.createManagedEffect)('HANDSHAKE_RECONNECT', function (context) { return context; }); diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index 88ae4af65..ee60fdc64 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.reconnectingRetry = exports.reconnectingGiveup = exports.reconnectingFailure = exports.reconnectingSuccess = exports.receivingFailure = exports.receivingSuccess = exports.handshakingReconnectingRetry = exports.handshakingReconnectingGiveup = exports.handshakingReconnectingFailure = exports.handshakingReconnectingSuccess = exports.handshakingFailure = exports.handshakingSuccess = exports.restore = exports.reconnect = exports.disconnect = exports.subscriptionChange = void 0; var core_1 = require("./core"); -exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGE', function (channels, groups) { return ({ +exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', function (channels, groups) { return ({ channels: channels, groups: groups, }); }); @@ -14,20 +14,20 @@ exports.restore = (0, core_1.createEvent)('RESTORE', function (channels, groups, timetoken: timetoken, region: region, }); }); -exports.handshakingSuccess = (0, core_1.createEvent)('HANDSHAKING_SUCCESS', function (cursor) { return cursor; }); -exports.handshakingFailure = (0, core_1.createEvent)('HANDSHAKING_FAILURE', function (error) { return error; }); +exports.handshakingSuccess = (0, core_1.createEvent)('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); +exports.handshakingFailure = (0, core_1.createEvent)('HANDSHAKE_FAILURE', function (error) { return error; }); exports.handshakingReconnectingSuccess = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_SUCCESS', function (cursor) { return ({ cursor: cursor, }); }); -exports.handshakingReconnectingFailure = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_FAILURE', function (error) { return error; }); +exports.handshakingReconnectingFailure = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); exports.handshakingReconnectingGiveup = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_GIVEUP', function () { return ({}); }); exports.handshakingReconnectingRetry = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_RETRY', function () { return ({}); }); -exports.receivingSuccess = (0, core_1.createEvent)('RECEIVING_SUCCESS', function (cursor, events) { return ({ +exports.receivingSuccess = (0, core_1.createEvent)('RECEIVE_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); -exports.receivingFailure = (0, core_1.createEvent)('RECEIVING_FAILURE', function (error) { return error; }); -exports.reconnectingSuccess = (0, core_1.createEvent)('RECEIVING_RECONNECTING_SUCCESS', function (cursor, events) { return ({ +exports.receivingFailure = (0, core_1.createEvent)('RECEIVE_FAILURE', function (error) { return error; }); +exports.reconnectingSuccess = (0, core_1.createEvent)('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); diff --git a/lib/event-engine/states/handshake_failure.js b/lib/event-engine/states/handshake_failure.js index e6295d151..4fd6cf486 100644 --- a/lib/event-engine/states/handshake_failure.js +++ b/lib/event-engine/states/handshake_failure.js @@ -17,6 +17,7 @@ var effects_1 = require("../effects"); var events_1 = require("../events"); var handshake_reconnecting_1 = require("./handshake_reconnecting"); var handshake_stopped_1 = require("./handshake_stopped"); +var handshaking_1 = require("./handshaking"); exports.HandshakeFailureState = new state_1.State('HANDSHAKE_FAILURE'); exports.HandshakeFailureState.onEnter(function (context) { return (0, effects_1.emitStatus)({ category: 'PNNetworkIssuesCategory' }); }); exports.HandshakeFailureState.on(events_1.handshakingReconnectingRetry.type, function (context) { @@ -28,3 +29,4 @@ exports.HandshakeFailureState.on(events_1.disconnect.type, function (context) { groups: context.groups, }); }); +exports.HandshakeFailureState.on(events_1.reconnect.type, function (context) { return handshaking_1.HandshakingState.with(__assign({}, context)); }); diff --git a/lib/event-engine/states/handshake_reconnecting.js b/lib/event-engine/states/handshake_reconnecting.js index c5f575cea..319e638d9 100644 --- a/lib/event-engine/states/handshake_reconnecting.js +++ b/lib/event-engine/states/handshake_reconnecting.js @@ -17,6 +17,7 @@ var effects_1 = require("../effects"); var events_1 = require("../events"); var handshake_failure_1 = require("./handshake_failure"); var handshake_stopped_1 = require("./handshake_stopped"); +var handshaking_1 = require("./handshaking"); var receiving_1 = require("./receiving"); exports.HandshakeReconnectingState = new state_1.State('HANDSHAKE_RECONNECTING'); exports.HandshakeReconnectingState.onEnter(function (context) { return (0, effects_1.handshakeReconnect)(context); }); @@ -44,3 +45,6 @@ exports.HandshakeReconnectingState.on(events_1.disconnect.type, function (contex groups: context.groups, }); }); +exports.HandshakeReconnectingState.on(events_1.subscriptionChange.type, function (_, event) { + return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); +}); diff --git a/lib/event-engine/states/handshake_stopped.js b/lib/event-engine/states/handshake_stopped.js index 90d58460d..606ba112d 100644 --- a/lib/event-engine/states/handshake_stopped.js +++ b/lib/event-engine/states/handshake_stopped.js @@ -16,8 +16,8 @@ var state_1 = require("../core/state"); var events_1 = require("../events"); var handshaking_1 = require("./handshaking"); exports.HandshakeStoppedState = new state_1.State('STOPPED'); -exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (_context, event) { - return exports.HandshakeStoppedState.with({ +exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (_, event) { + return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, }); diff --git a/lib/event-engine/states/receive_reconnecting.js b/lib/event-engine/states/receive_reconnecting.js index ea59ddae4..255889833 100644 --- a/lib/event-engine/states/receive_reconnecting.js +++ b/lib/event-engine/states/receive_reconnecting.js @@ -37,12 +37,26 @@ exports.ReceiveReconnectingState.on(events_1.reconnectingGiveup.type, function ( channels: context.channels, cursor: context.cursor, reason: context.reason, - }); + }, [(0, effects_1.emitStatus)({ category: 'PNDisconnectedCategory' })]); }); exports.ReceiveReconnectingState.on(events_1.disconnect.type, function (context) { return receive_stopped_1.ReceiveStoppedState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, + }, [(0, effects_1.emitStatus)({ category: 'PNDisconnectedCategory' })]); +}); +exports.ReceiveReconnectingState.on(events_1.restore.type, function (context) { + return receiving_1.ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }); +}); +exports.ReceiveReconnectingState.on(events_1.subscriptionChange.type, function (context, event) { + return receiving_1.ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, }); }); diff --git a/lib/event-engine/states/receive_stopped.js b/lib/event-engine/states/receive_stopped.js index 46d7856e4..ac3fd8eff 100644 --- a/lib/event-engine/states/receive_stopped.js +++ b/lib/event-engine/states/receive_stopped.js @@ -17,7 +17,7 @@ var events_1 = require("../events"); var receiving_1 = require("./receiving"); exports.ReceiveStoppedState = new state_1.State('STOPPED'); exports.ReceiveStoppedState.on(events_1.subscriptionChange.type, function (context, event) { - return exports.ReceiveStoppedState.with({ + return receiving_1.ReceivingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: context.cursor, diff --git a/lib/event-engine/states/receiving.js b/lib/event-engine/states/receiving.js index 2128e2fd4..1d54086b6 100644 --- a/lib/event-engine/states/receiving.js +++ b/lib/event-engine/states/receiving.js @@ -19,8 +19,8 @@ var unsubscribed_1 = require("./unsubscribed"); var receive_reconnecting_1 = require("./receive_reconnecting"); var receive_stopped_1 = require("./receive_stopped"); exports.ReceivingState = new state_1.State('RECEIVING'); +exports.ReceivingState.onEnter(function (_) { return (0, effects_1.emitStatus)({ category: 'PNConnectedCategory' }); }); exports.ReceivingState.onEnter(function (context) { return (0, effects_1.receiveEvents)(context.channels, context.groups, context.cursor); }); -exports.ReceivingState.onEnter(function (context) { return (0, effects_1.emitStatus)({ category: 'PNConnectedCategory' }); }); exports.ReceivingState.onExit(function () { return effects_1.receiveEvents.cancel; }); exports.ReceivingState.on(events_1.receivingSuccess.type, function (context, event) { return exports.ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [(0, effects_1.emitEvents)(event.payload.events)]); @@ -39,5 +39,5 @@ exports.ReceivingState.on(events_1.disconnect.type, function (context) { channels: context.channels, groups: context.groups, cursor: context.cursor, - }); + }, [(0, effects_1.emitStatus)({ category: 'PNDisconnectedCategory' })]); }); diff --git a/package.json b/package.json index ddfc2e5d3..0a4487cc6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pubnub", - "version": "7.2.2", + "version": "7.2.3", "author": "PubNub ", "description": "Publish & Subscribe Real-time Messaging with PubNub", "scripts": { @@ -19,7 +19,7 @@ "test:feature:fileupload:node": "ts-mocha -p tsconfig.mocha.json --no-config --require test/setup.js --reporter spec test/feature/file_upload.node.test.js", "test:contract": "npm run test:contract:prepare && npm run test:contract:start", "test:contract:prepare": "rimraf test/specs && git clone --branch master --depth 1 git@github.com:pubnub/sdk-specifications.git test/specs", - "test:contract:start": "cucumber-js -p default --tags 'not @na=js and not @beta and not @skip'", + "test:contract:start": "cucumber-js -p default --tags 'not @na=js'", "test:contract:beta": "cucumber-js -p default --tags 'not @na=js and @beta and not @skip'", "contract:refresh": "rimraf dist/contract && git clone --branch master git@github.com:pubnub/service-contract-mock.git dist/contract && npm install --prefix dist/contract && npm run refresh-files --prefix dist/contract", "contract:server": "npm start --prefix dist/contract consumer", diff --git a/src/core/components/_endpoint.ts b/src/core/components/_endpoint.ts deleted file mode 100644 index 66476c29f..000000000 --- a/src/core/components/_endpoint.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { Operation } from '../constants/operations'; - -type Modules = { - config: any; -}; - -export type Endpoint = { - getOperation(): Operation | string; - getRequestTimeout(modules: Modules): number; - isAuthSupported(): boolean; - - validateParams(modules: Modules, params: P): string | void; - - usePost?(modules: Modules, params: P): boolean; - - getURL?(modules: Modules, params: P): string; - postURL?(modules: Modules, params: P): string; - - prepareParams?(modules: Modules, params: P): Record; - postPayload?(modules: Modules, params: P): unknown; - - handleResponse(modules: Modules, response: any): R; -}; diff --git a/src/core/constants/categories.js b/src/core/constants/categories.js index 5c0cbb0e8..76809b824 100644 --- a/src/core/constants/categories.js +++ b/src/core/constants/categories.js @@ -27,4 +27,6 @@ export default { PNConnectedCategory: 'PNConnectedCategory', PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', + + PNDisconnectedCategory: 'PNDisconnectedCategory', }; diff --git a/src/core/constants/operations.ts b/src/core/constants/operations.ts deleted file mode 100644 index 75e1467d0..000000000 --- a/src/core/constants/operations.ts +++ /dev/null @@ -1,164 +0,0 @@ -export enum Operation { - Time = 'PNTimeOperation', - - History = 'PNHistoryOperation', - DeleteMessages = 'PNDeleteMessagesOperation', - FetchMessages = 'PNFetchMessagesOperation', - MessageCounts = 'PNMessageCountsOperation', - - Subscribe = 'PNSubscribeOperation', - Unsubscribe = 'PNUnsubscribeOperation', - Publish = 'PNPublishOperation', - Signal = 'PNSignalOperation', - - AddMessageAction = 'PNAddActionOperation', - RemoveMessageAction = 'PNRemoveMessageActionOperation', - GetMessageActions = 'PNGetMessageActionsOperation', - - CreateUser = 'PNCreateUserOperation', - UpdateUser = 'PNUpdateUserOperation', - RemoveUser = 'PNRemoveUserOperation', - FetchUser = 'PNFetchUserOperation', - GetUsers = 'PNGetUsersOperation', - CreateSpace = 'PNCreateSpaceOperation', - UpdateSpace = 'PNUpdateSpaceOperation', - RemoveSpace = 'PNRemoveSpaceOperation', - FetchSpace = 'PNFetchSpaceOperation', - GetSpaces = 'PNGetSpacesOperation', - GetMembers = 'PNGetMembersOperation', - UpdateMembers = 'PNUpdateMembersOperation', - GetMemberships = 'PNGetMembershipsOperation', - UpdateMemberships = 'PNUpdateMembershipsOperation', - - ListFiles = 'PNListFilesOperation', - GenerateUploadUrl = 'PNGenerateUploadUrlOperation', - PublishFile = 'PNPublishFileOperation', - GetFileUrl = 'PNGetFileUrlOperation', - DownloadFile = 'PNDownloadFileOperation', - - GetAllUUIDMetadata = 'PNGetAllUUIDMetadataOperation', - GetUUIDMetadata = 'PNGetUUIDMetadataOperation', - SetUUIDMetadata = 'PNSetUUIDMetadataOperation', - RemoveUUIDMetadata = 'PNRemoveUUIDMetadataOperation', - GetAllChannelMetadata = 'PNGetAllChannelMetadataOperation', - GetChannelMetadata = 'PNGetChannelMetadataOperation', - SetChannelMetadata = 'PNSetChannelMetadataOperation', - RemoveChannelMetadata = 'PNRemoveChannelMetadataOperation', - SetMembers = 'PNSetMembersOperation', - SetMemberships = 'PNSetMembershipsOperation', - - PushNotificationEnabledChannels = 'PNPushNotificationEnabledChannelsOperation', - RemoveAllPushNotifications = 'PNRemoveAllPushNotificationsOperation', - - WhereNow = 'PNWhereNowOperation', - SetState = 'PNSetStateOperation', - HereNow = 'PNHereNowOperation', - GetState = 'PNGetStateOperation', - Heartbeat = 'PNHeartbeatOperation', - - ChannelGroups = 'PNChannelGroupsOperation', - RemoveGroup = 'PNRemoveGroupOperation', - ChannelsForGroup = 'PNChannelsForGroupOperation', - AddChannelsToGroup = 'PNAddChannelsToGroupOperation', - RemoveChannelsFromGroup = 'PNRemoveChannelsFromGroupOperation', - - AccessManagerGrant = 'PNAccessManagerGrant', - AccessManagerGrantToken = 'PNAccessManagerGrantToken', - AccessManagerAudit = 'PNAccessManagerAudit', - AccessManagerRevokeToken = 'PNAccessManagerRevokeToken', - - Handshake = 'PNHandshakeOperation', - ReceiveMessages = 'PNReceiveMessagesOperation', -} - -export default { - PNTimeOperation: 'PNTimeOperation', - - PNHistoryOperation: 'PNHistoryOperation', - PNDeleteMessagesOperation: 'PNDeleteMessagesOperation', - PNFetchMessagesOperation: 'PNFetchMessagesOperation', - PNMessageCounts: 'PNMessageCountsOperation', - - // pubsub - PNSubscribeOperation: 'PNSubscribeOperation', - PNUnsubscribeOperation: 'PNUnsubscribeOperation', - PNPublishOperation: 'PNPublishOperation', - PNSignalOperation: 'PNSignalOperation', - - // Actions API - PNAddMessageActionOperation: 'PNAddActionOperation', - PNRemoveMessageActionOperation: 'PNRemoveMessageActionOperation', - PNGetMessageActionsOperation: 'PNGetMessageActionsOperation', - - // Objects API - PNCreateUserOperation: 'PNCreateUserOperation', - PNUpdateUserOperation: 'PNUpdateUserOperation', - PNRemoveUserOperation: 'PNRemoveUserOperation', - PNFetchUserOperation: 'PNFetchUserOperation', - PNGetUsersOperation: 'PNGetUsersOperation', - PNCreateSpaceOperation: 'PNCreateSpaceOperation', - PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', - PNRemoveSpaceOperation: 'PNRemoveSpaceOperation', - PNFetchSpaceOperation: 'PNFetchSpaceOperation', - PNGetSpacesOperation: 'PNGetSpacesOperation', - PNGetMembersOperation: 'PNGetMembersOperation', - PNUpdateMembersOperation: 'PNUpdateMembersOperation', - PNGetMembershipsOperation: 'PNGetMembershipsOperation', - PNUpdateMembershipsOperation: 'PNUpdateMembershipsOperation', - - // File Upload API v1 - PNListFilesOperation: 'PNListFilesOperation', - PNGenerateUploadUrlOperation: 'PNGenerateUploadUrlOperation', - PNPublishFileOperation: 'PNPublishFileOperation', - PNGetFileUrlOperation: 'PNGetFileUrlOperation', - PNDownloadFileOperation: 'PNDownloadFileOperation', - - // Objects API v2 - // UUID - PNGetAllUUIDMetadataOperation: 'PNGetAllUUIDMetadataOperation', - PNGetUUIDMetadataOperation: 'PNGetUUIDMetadataOperation', - PNSetUUIDMetadataOperation: 'PNSetUUIDMetadataOperation', - PNRemoveUUIDMetadataOperation: 'PNRemoveUUIDMetadataOperation', - // channel - PNGetAllChannelMetadataOperation: 'PNGetAllChannelMetadataOperation', - PNGetChannelMetadataOperation: 'PNGetChannelMetadataOperation', - PNSetChannelMetadataOperation: 'PNSetChannelMetadataOperation', - PNRemoveChannelMetadataOperation: 'PNRemoveChannelMetadataOperation', - // member - // PNGetMembersOperation: 'PNGetMembersOperation', - PNSetMembersOperation: 'PNSetMembersOperation', - // PNGetMembershipsOperation: 'PNGetMembersOperation', - PNSetMembershipsOperation: 'PNSetMembershipsOperation', - - // push - PNPushNotificationEnabledChannelsOperation: 'PNPushNotificationEnabledChannelsOperation', - PNRemoveAllPushNotificationsOperation: 'PNRemoveAllPushNotificationsOperation', - // - - // presence - PNWhereNowOperation: 'PNWhereNowOperation', - PNSetStateOperation: 'PNSetStateOperation', - PNHereNowOperation: 'PNHereNowOperation', - PNGetStateOperation: 'PNGetStateOperation', - PNHeartbeatOperation: 'PNHeartbeatOperation', - // - - // channel group - PNChannelGroupsOperation: 'PNChannelGroupsOperation', - PNRemoveGroupOperation: 'PNRemoveGroupOperation', - PNChannelsForGroupOperation: 'PNChannelsForGroupOperation', - PNAddChannelsToGroupOperation: 'PNAddChannelsToGroupOperation', - PNRemoveChannelsFromGroupOperation: 'PNRemoveChannelsFromGroupOperation', - // - - // PAM - PNAccessManagerGrant: 'PNAccessManagerGrant', - PNAccessManagerGrantToken: 'PNAccessManagerGrantToken', - PNAccessManagerAudit: 'PNAccessManagerAudit', - PNAccessManagerRevokeToken: 'PNAccessManagerRevokeToken', - // - - // subscription utilities - PNHandshakeOperation: 'PNHandshakeOperation', - PNReceiveMessagesOperation: 'PNReceiveMessagesOperation', -} as const; diff --git a/src/core/endpoints/user/create.ts b/src/core/endpoints/user/create.ts deleted file mode 100644 index cb0a1e34b..000000000 --- a/src/core/endpoints/user/create.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Endpoint } from '../../components/_endpoint'; -import operationConstants from '../../constants/operations'; - -import utils from '../../utils'; - -const endpoint: Endpoint<{ data: any; userId: string }, { status: number; data: any }> = { - getOperation: () => operationConstants.PNCreateUserOperation, - - validateParams: (_, params) => { - if (!params?.data) { - return 'Data cannot be empty'; - } - }, - - usePost: () => true, - - postURL: ({ config }, params) => - `/v3/objects/${config.subscribeKey}/users/${utils.encodeString(params.userId ?? config.getUserId())}`, - - postPayload: (_, params) => params.data, - - getRequestTimeout: ({ config }) => config.getTransactionTimeout(), - - isAuthSupported: () => true, - - prepareParams: ({ config }, params) => { - const queryParams = { - uuid: params?.userId ?? config.getUserId(), - }; - - return queryParams; - }, - - handleResponse: (_, response) => ({ - status: response.status, - data: response.data, - }), -}; - -export default endpoint; diff --git a/src/core/endpoints/user/fetch.ts b/src/core/endpoints/user/fetch.ts deleted file mode 100644 index 1e9da8519..000000000 --- a/src/core/endpoints/user/fetch.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Endpoint } from '../../components/_endpoint'; -import operationConstants from '../../constants/operations'; - -import utils from '../../utils'; - -const endpoint: Endpoint<{ userId?: string }, { status: number; data: any }> = { - getOperation: () => operationConstants.PNFetchUserOperation, - - validateParams: () => { - // No required parameters. - }, - - getURL: ({ config }, params) => - `/v3/objects/${config.subscribeKey}/users/${utils.encodeString(params?.userId ?? config.getUserId())}`, - - getRequestTimeout: ({ config }) => config.getTransactionTimeout(), - - isAuthSupported: () => true, - - prepareParams: ({ config }, params) => { - const queryParams = { uuid: params?.userId ?? config.getUserId() }; - - return queryParams; - }, - - handleResponse: (_, response) => ({ - status: response.status, - data: response.data, - }), -}; - -export default endpoint; diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 8b9bc6f1f..73ed9b474 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -323,9 +323,9 @@ export default class { const eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: (attempts) => attempts * 25, + getRetryDelay: (attempts) => attempts * 2, delay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), - shouldRetry: (error, attempts) => attempts < 3, + shouldRetry: (error, attempts) => attempts < 2, emitEvents: (events) => { for (const event of events) { listenerManager.announceMessage(event); diff --git a/src/event-engine/effects.ts b/src/event-engine/effects.ts index 6b8e6871a..ddbf6dabc 100644 --- a/src/event-engine/effects.ts +++ b/src/event-engine/effects.ts @@ -9,11 +9,11 @@ export const handshake = createManagedEffect('HANDSHAKE', (channels: string[], g })); export const receiveEvents = createManagedEffect( - 'RECEIVE_EVENTS', + 'RECEIVE_MESSAGES', (channels: string[], groups: string[], cursor: Cursor) => ({ channels, groups, cursor }), ); -export const emitEvents = createEffect('EMIT_EVENTS', (events: any[]) => events); +export const emitEvents = createEffect('EMIT_MESSAGES', (events: any[]) => events); export const emitStatus = createEffect('EMIT_STATUS', (status: any) => status); diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index e5f2a8a7b..1161e1f0a 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -2,7 +2,7 @@ import { PubNubError } from '../core/components/endpoint'; import { Cursor } from '../models/Cursor'; import { createEvent, MapOf } from './core'; -export const subscriptionChange = createEvent('SUBSCRIPTION_CHANGE', (channels: string[], groups: string[]) => ({ +export const subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', (channels: string[], groups: string[]) => ({ channels, groups, })); @@ -19,26 +19,23 @@ export const restore = createEvent( }), ); -export const handshakingSuccess = createEvent('HANDSHAKING_SUCCESS', (cursor: Cursor) => cursor); -export const handshakingFailure = createEvent('HANDSHAKING_FAILURE', (error: PubNubError) => error); +export const handshakingSuccess = createEvent('HANDSHAKE_SUCCESS', (cursor: Cursor) => cursor); +export const handshakingFailure = createEvent('HANDSHAKE_FAILURE', (error: PubNubError) => error); export const handshakingReconnectingSuccess = createEvent('HANDSHAKING_RECONNECTING_SUCCESS', (cursor: Cursor) => ({ cursor, })); -export const handshakingReconnectingFailure = createEvent( - 'HANDSHAKING_RECONNECTING_FAILURE', - (error: PubNubError) => error, -); +export const handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', (error: PubNubError) => error); export const handshakingReconnectingGiveup = createEvent('HANDSHAKING_RECONNECTING_GIVEUP', () => ({})); export const handshakingReconnectingRetry = createEvent('HANDSHAKING_RECONNECTING_RETRY', () => ({})); -export const receivingSuccess = createEvent('RECEIVING_SUCCESS', (cursor: Cursor, events: any[]) => ({ +export const receivingSuccess = createEvent('RECEIVE_SUCCESS', (cursor: Cursor, events: any[]) => ({ cursor, events, })); -export const receivingFailure = createEvent('RECEIVING_FAILURE', (error: PubNubError) => error); +export const receivingFailure = createEvent('RECEIVE_FAILURE', (error: PubNubError) => error); -export const reconnectingSuccess = createEvent('RECEIVING_RECONNECTING_SUCCESS', (cursor: Cursor, events: any[]) => ({ +export const reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', (cursor: Cursor, events: any[]) => ({ cursor, events, })); diff --git a/src/event-engine/states/handshake_failure.ts b/src/event-engine/states/handshake_failure.ts index b1f956dd0..0f0fed581 100644 --- a/src/event-engine/states/handshake_failure.ts +++ b/src/event-engine/states/handshake_failure.ts @@ -1,9 +1,10 @@ import { State } from '../core/state'; import { Effects, emitStatus } from '../effects'; -import { disconnect, Events, handshakingReconnectingRetry } from '../events'; +import { disconnect, Events, handshakingReconnectingRetry, reconnect } from '../events'; import { PubNubError } from '../../core/components/endpoint'; import { HandshakeReconnectingState } from './handshake_reconnecting'; import { HandshakeStoppedState } from './handshake_stopped'; +import { HandshakingState } from './handshaking'; export type HandshakeFailureStateContext = { channels: string[]; @@ -29,3 +30,5 @@ HandshakeFailureState.on(disconnect.type, (context) => groups: context.groups, }), ); + +HandshakeFailureState.on(reconnect.type, (context) => HandshakingState.with({ ...context })); diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index 5dfac7f14..8ef9b8f7f 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -7,9 +7,11 @@ import { handshakingReconnectingFailure, handshakingReconnectingGiveup, handshakingReconnectingSuccess, + subscriptionChange, } from '../events'; import { HandshakeFailureState } from './handshake_failure'; import { HandshakeStoppedState } from './handshake_stopped'; +import { HandshakingState } from './handshaking'; import { ReceivingState } from './receiving'; export type HandshakeReconnectingStateContext = { @@ -53,3 +55,8 @@ HandshakeReconnectingState.on(disconnect.type, (context) => groups: context.groups, }), ); + + +HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => + HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), +); diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index 71a061c61..483d214be 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -10,8 +10,8 @@ type HandshakeStoppedStateContext = { export const HandshakeStoppedState = new State('STOPPED'); -HandshakeStoppedState.on(subscriptionChange.type, (_context, event) => - HandshakeStoppedState.with({ +HandshakeStoppedState.on(subscriptionChange.type, (_, event) => + HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, }), diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index dbf825922..b5668f515 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -1,8 +1,16 @@ import { PubNubError } from '../../core/components/endpoint'; import { Cursor } from '../../models/Cursor'; import { State } from '../core/state'; -import { Effects, emitEvents, reconnect } from '../effects'; -import { disconnect, Events, reconnectingFailure, reconnectingGiveup, reconnectingSuccess } from '../events'; +import { Effects, emitEvents, reconnect, emitStatus } from '../effects'; +import { + disconnect, + Events, + reconnectingFailure, + reconnectingGiveup, + reconnectingSuccess, + restore, + subscriptionChange, +} from '../events'; import { ReceivingState } from './receiving'; import { ReceiveFailureState } from './receive_failure'; import { ReceiveStoppedState } from './receive_stopped'; @@ -39,18 +47,40 @@ ReceiveReconnectingState.on(reconnectingFailure.type, (context, event) => ); ReceiveReconnectingState.on(reconnectingGiveup.type, (context) => - ReceiveFailureState.with({ - groups: context.groups, - channels: context.channels, - cursor: context.cursor, - reason: context.reason, - }), + ReceiveFailureState.with( + { + groups: context.groups, + channels: context.channels, + cursor: context.cursor, + reason: context.reason, + }, + [emitStatus({ category: 'PNDisconnectedCategory' })], + ), ); ReceiveReconnectingState.on(disconnect.type, (context) => - ReceiveStoppedState.with({ + ReceiveStoppedState.with( + { + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }, + [emitStatus({ category: 'PNDisconnectedCategory' })], + ), +); + +ReceiveReconnectingState.on(restore.type, (context) => + ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, }), ); + +ReceiveReconnectingState.on(subscriptionChange.type, (context, event) => + ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }), +); diff --git a/src/event-engine/states/receive_stopped.ts b/src/event-engine/states/receive_stopped.ts index 2b66a1337..6bca4abf9 100644 --- a/src/event-engine/states/receive_stopped.ts +++ b/src/event-engine/states/receive_stopped.ts @@ -13,7 +13,7 @@ type ReceiveStoppedStateContext = { export const ReceiveStoppedState = new State('STOPPED'); ReceiveStoppedState.on(subscriptionChange.type, (context, event) => - ReceiveStoppedState.with({ + ReceivingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: context.cursor, diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index 4a779dc72..5bb58e259 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -14,8 +14,8 @@ export type ReceivingStateContext = { export const ReceivingState = new State('RECEIVING'); +ReceivingState.onEnter((_) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onEnter((context) => receiveEvents(context.channels, context.groups, context.cursor)); -ReceivingState.onEnter((context) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onExit(() => receiveEvents.cancel); ReceivingState.on(receivingSuccess.type, (context, event) => { @@ -38,10 +38,13 @@ ReceivingState.on(receivingFailure.type, (context, event) => { }); }); -ReceivingState.on(disconnect.type, (context) => - ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }), -); +ReceivingState.on(disconnect.type, (context) => { + return ReceiveStoppedState.with( + { + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }, + [emitStatus({ category: 'PNDisconnectedCategory' })], + ); +}); diff --git a/test/contract/definitions/event-engine.ts b/test/contract/definitions/event-engine.ts index ce14c0e6e..8d5c8f5db 100644 --- a/test/contract/definitions/event-engine.ts +++ b/test/contract/definitions/event-engine.ts @@ -79,7 +79,7 @@ class EventEngineSteps { const timetoken = await this.pubnub?.publish({ channel: 'test', message: { content: 'Hello world!' } }); } - @then('I receive an error') + @then('I receive an error in my subscribe response') async thenIReceiveError() { const status = await this.statusPromise; From c030e3109074e655d344b311c1dfc28f4dad5e99 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 6 Jul 2023 12:27:29 +0530 Subject: [PATCH 10/63] prettier! --- src/event-engine/states/handshake_reconnecting.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index 8ef9b8f7f..b6a426b09 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -56,7 +56,6 @@ HandshakeReconnectingState.on(disconnect.type, (context) => }), ); - HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), ); From e01236ceaaf76813e10935ae7c4cfa3c3ae32c01 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 6 Jul 2023 16:06:31 +0530 Subject: [PATCH 11/63] fix: test and version mismatch from branch merge --- src/core/components/config.js | 2 +- test/unit/event_engine.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/components/config.js b/src/core/components/config.js index 09d01c9c4..81d257061 100644 --- a/src/core/components/config.js +++ b/src/core/components/config.js @@ -339,7 +339,7 @@ export default class { } getVersion() { - return '7.2.2'; + return '7.2.3'; } _addPnsdkSuffix(name, suffix) { diff --git a/test/unit/event_engine.test.ts b/test/unit/event_engine.test.ts index db01a60c4..89a572aa7 100644 --- a/test/unit/event_engine.test.ts +++ b/test/unit/event_engine.test.ts @@ -105,7 +105,7 @@ describe('EventEngine', () => { pubnub.subscribe({ channels: ['test'] }); - await forEvent('HANDSHAKING_SUCCESS', 1000); + await forEvent('HANDSHAKE_SUCCESS', 1000); pubnub.unsubscribe({ channels: ['test'] }); From 4f77d2006cac6a820d23c0064f8112de73de704f Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 6 Jul 2023 16:17:55 +0530 Subject: [PATCH 12/63] fix: version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b65ac10f..7ffead572 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ You will need the publish and subscribe keys to authenticate your app. Get your npm install pubnub ``` * or download one of our builds from our CDN: - * https://cdn.pubnub.com/sdk/javascript/pubnub.7.2.2.js - * https://cdn.pubnub.com/sdk/javascript/pubnub.7.2.2.min.js + * https://cdn.pubnub.com/sdk/javascript/pubnub.7.2.3.js + * https://cdn.pubnub.com/sdk/javascript/pubnub.7.2.3.min.js 2. Configure your keys: From 0ac5cc73c07486f7e86dcb01086025ecd034f24b Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 11 Jul 2023 12:25:33 +0530 Subject: [PATCH 13/63] add: reconnection configuration --- dist/web/pubnub.js | 48 ++++++++++++++++++---- dist/web/pubnub.min.js | 2 +- lib/core/components/config.js | 18 +++++++- lib/core/pubnub-common.js | 11 ++++- lib/event-engine/core/reconnectionDelay.js | 20 +++++++++ lib/event-engine/events.js | 3 +- lib/event-engine/index.js | 4 +- lib/event-engine/states/handshaking.js | 5 ++- lib/event-engine/states/unsubscribed.js | 2 +- src/core/components/config.js | 15 +++++++ src/core/pubnub-common.js | 10 ++++- src/event-engine/core/reconnectionDelay.ts | 13 ++++++ src/event-engine/events.ts | 3 +- src/event-engine/index.ts | 4 +- src/event-engine/states/handshaking.ts | 6 ++- src/event-engine/states/unsubscribed.ts | 2 +- test/unit/event_engine.test.ts | 1 + 17 files changed, 143 insertions(+), 24 deletions(-) create mode 100644 lib/event-engine/core/reconnectionDelay.js create mode 100644 src/event-engine/core/reconnectionDelay.ts diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index d46d5384a..e46feaa0b 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -641,6 +641,8 @@ this.useRandomIVs = (_c = setup.useRandomIVs) !== null && _c !== void 0 ? _c : true; // flag for beta subscribe feature enablement this.enableSubscribeBeta = (_d = setup.enableSubscribeBeta) !== null && _d !== void 0 ? _d : false; + // reconnection configuration settings to apply reconnection settings in subscription + this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; // if location config exist and we are in https, force secure to true. if (typeof location !== 'undefined' && location.protocol === 'https:') { this.secure = true; @@ -768,7 +770,10 @@ return this; }; default_1.prototype.getVersion = function () { - return '7.2.2'; + return '7.2.3'; + }; + default_1.prototype.setReconnectionConfiguration = function (reconnectionPolicy, maximumReconnectionRetries) { + this.reconnectionConfiguration = __assign(__assign({}, config.reconnectionConfiguration), { reconnectionPolicy: reconnectionPolicy, maximumReconnectionRetries: maximumReconnectionRetries }); }; default_1.prototype._addPnsdkSuffix = function (name, suffix) { this._PNSDKSuffix[name] = suffix; @@ -6969,9 +6974,10 @@ var reconnect$1 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); - var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups) { return ({ + var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ channels: channels, groups: groups, + timetoken: timetoken }); }); var disconnect = createEvent('DISCONNECT', function () { return ({}); }); var reconnect = createEvent('RECONNECT', function () { return ({}); }); @@ -7337,7 +7343,10 @@ return ReceivingState.with({ channels: context.channels, groups: context.groups, - cursor: event.payload, + cursor: { + timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + region: event.payload.region, + }, }); }); HandshakingState.on(handshakingFailure.type, function (context, event) { @@ -7352,7 +7361,7 @@ var UnsubscribedState = new State('UNSUBSCRIBED'); UnsubscribedState.on(subscriptionChange.type, function (_, event) { - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, timetoken: event.payload.timetoken }); }); var EventEngine = /** @class */ (function () { @@ -7377,10 +7386,10 @@ configurable: true }); EventEngine.prototype.subscribe = function (_a) { - var channels = _a.channels, groups = _a.groups; + var channels = _a.channels, groups = _a.groups, timetoken = _a.timetoken; this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); - this.engine.transition(subscriptionChange(this.channels, this.groups)); + this.engine.transition(subscriptionChange(this.channels, this.groups, timetoken !== null && timetoken !== void 0 ? timetoken : '0')); }; EventEngine.prototype.unsubscribe = function (_a) { var channels = _a.channels, groups = _a.groups; @@ -7407,10 +7416,28 @@ return EventEngine; }()); + var ReconnectionDelay = /** @class */ (function () { + function ReconnectionDelay() { + } + ReconnectionDelay.getDelay = function (policy, attempts, backoff) { + var backoffValue = backoff !== null && backoff !== void 0 ? backoff : 5; + switch (policy.toUpperCase()) { + case 'LINEAR': + return attempts * backoffValue + Math.random() * 1000; + case 'EXPONENTIAL': + return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; + default: + throw new Error('invalid policy'); + } + }; + return ReconnectionDelay; + }()); + var default_1$3 = /** @class */ (function () { // function default_1(setup) { var _this = this; + var _a; var networking = setup.networking, cbor = setup.cbor; var config = new default_1$b({ setup: setup }); this._config = config; @@ -7449,12 +7476,14 @@ this.handshake = endpointCreator.bind(this, modules, endpoint$1); this.receiveMessages = endpointCreator.bind(this, modules, endpoint); if (config.enableSubscribeBeta === true) { + var policy_1 = modules.config.reconnectionConfiguration.reconnectionPolicy; + var maxRetries_1 = (_a = modules.config.reconnectionConfiguration.maximumReconnectionRetries) !== null && _a !== void 0 ? _a : 0; var eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return attempts * 2; }, + getRetryDelay: function (attempts) { return ReconnectionDelay.getDelay(policy_1, maxRetries_1); }, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (error, attempts) { return attempts < 2; }, + shouldRetry: function (_, attempts) { return maxRetries_1 >= attempts && policy_1 && policy_1 != 'None'; }, emitEvents: function (events) { var e_1, _a; try { @@ -7477,6 +7506,9 @@ }); this.subscribe = eventEngine.subscribe.bind(eventEngine); this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); + this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); + this.reconnect = eventEngine.reconnect.bind(eventEngine); + this.disconnect = eventEngine.disconnect.bind(eventEngine); this.eventEngine = eventEngine; } else { diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 2d1a81bc4..25b5eaa2a 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -14,4 +14,4 @@ PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var v=function e(){var i,h,v=l(),b=v>>5,m=31&v;if(7===b)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(b<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(b))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var T;if(h<0)for(T=[];!f();)T.push(e());else for(T=new Array(h),i=0;i=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.2"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],N=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,N,k,a,12,c[1]),k=t(k,T,w,N,l,17,c[2]),N=t(N,k,T,w,p,22,c[3]);w=t(w,N,k,T,h,7,c[4]),T=t(T,w,N,k,f,12,c[5]),k=t(k,T,w,N,d,17,c[6]),N=t(N,k,T,w,g,22,c[7]),w=t(w,N,k,T,y,7,c[8]),T=t(T,w,N,k,v,12,c[9]),k=t(k,T,w,N,b,17,c[10]),N=t(N,k,T,w,m,22,c[11]),w=t(w,N,k,T,_,7,c[12]),T=t(T,w,N,k,O,12,c[13]),k=t(k,T,w,N,P,17,c[14]),w=n(w,N=t(N,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,N,k,d,9,c[17]),k=n(k,T,w,N,m,14,c[18]),N=n(N,k,T,w,u,20,c[19]),w=n(w,N,k,T,f,5,c[20]),T=n(T,w,N,k,b,9,c[21]),k=n(k,T,w,N,S,14,c[22]),N=n(N,k,T,w,h,20,c[23]),w=n(w,N,k,T,v,5,c[24]),T=n(T,w,N,k,P,9,c[25]),k=n(k,T,w,N,p,14,c[26]),N=n(N,k,T,w,y,20,c[27]),w=n(w,N,k,T,O,5,c[28]),T=n(T,w,N,k,l,9,c[29]),k=n(k,T,w,N,g,14,c[30]),w=r(w,N=n(N,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,N,k,y,11,c[33]),k=r(k,T,w,N,m,16,c[34]),N=r(N,k,T,w,P,23,c[35]),w=r(w,N,k,T,a,4,c[36]),T=r(T,w,N,k,h,11,c[37]),k=r(k,T,w,N,g,16,c[38]),N=r(N,k,T,w,b,23,c[39]),w=r(w,N,k,T,O,4,c[40]),T=r(T,w,N,k,u,11,c[41]),k=r(k,T,w,N,p,16,c[42]),N=r(N,k,T,w,d,23,c[43]),w=r(w,N,k,T,v,4,c[44]),T=r(T,w,N,k,_,11,c[45]),k=r(k,T,w,N,S,16,c[46]),w=i(w,N=r(N,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,N,k,g,10,c[49]),k=i(k,T,w,N,P,15,c[50]),N=i(N,k,T,w,f,21,c[51]),w=i(w,N,k,T,_,6,c[52]),T=i(T,w,N,k,p,10,c[53]),k=i(k,T,w,N,b,15,c[54]),N=i(N,k,T,w,a,21,c[55]),w=i(w,N,k,T,y,6,c[56]),T=i(T,w,N,k,S,10,c[57]),k=i(k,T,w,N,d,15,c[58]),N=i(N,k,T,w,O,21,c[59]),w=i(w,N,k,T,h,6,c[60]),T=i(T,w,N,k,m,10,c[61]),k=i(k,T,w,N,l,15,c[62]),N=i(N,k,T,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+N|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function E(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function C(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return C(e).map((function(t){return"".concat(t,"=").concat(E(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:E},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory"},j=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new N({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),R={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==R.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==R.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case R.PNPublishOperation:t="pub";break;case R.PNSignalOperation:t="sig";break;case R.PNHistoryOperation:case R.PNFetchMessagesOperation:case R.PNDeleteMessagesOperation:case R.PNMessageCounts:t="hist";break;case R.PNUnsubscribeOperation:case R.PNWhereNowOperation:case R.PNHereNowOperation:case R.PNHeartbeatOperation:case R.PNSetStateOperation:case R.PNGetStateOperation:t="pres";break;case R.PNAddChannelsToGroupOperation:case R.PNRemoveChannelsFromGroupOperation:case R.PNChannelGroupsOperation:case R.PNRemoveGroupOperation:case R.PNChannelsForGroupOperation:t="cg";break;case R.PNPushNotificationEnabledChannelsOperation:case R.PNRemoveAllPushNotificationsOperation:t="push";break;case R.PNCreateUserOperation:case R.PNUpdateUserOperation:case R.PNDeleteUserOperation:case R.PNGetUserOperation:case R.PNGetUsersOperation:case R.PNCreateSpaceOperation:case R.PNUpdateSpaceOperation:case R.PNDeleteSpaceOperation:case R.PNGetSpaceOperation:case R.PNGetSpacesOperation:case R.PNGetMembersOperation:case R.PNUpdateMembersOperation:case R.PNGetMembershipsOperation:case R.PNUpdateMembershipsOperation:t="obj";break;case R.PNAddMessageActionOperation:case R.PNRemoveMessageActionOperation:case R.PNGetMessageActionsOperation:t="msga";break;case R.PNAccessManagerGrant:case R.PNAccessManagerAudit:t="pam";break;case R.PNAccessManagerGrantToken:case R.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function W(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return R.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return R.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return R.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return R.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return R.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return R.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return R.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return R.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return R.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,T,k,N,E,C,A,M,j,R,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(E=(N=l).POSTFILE,C=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,E.apply(N,C.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,j=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,j.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(R=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(R,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},be={getOperation:function(){return R.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return R.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return R.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return R.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return R.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return R.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return R.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return R.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return R.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return R.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return R.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ce={getOperation:function(){return R.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return R.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return R.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var je=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var Re=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return R.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return R.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return R.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return R.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return R.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return R.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return R.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return R.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return R.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var We=Object.freeze({__proto__:null,getOperation:function(){return R.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Xe={getOperation:function(){return R.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return R.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(pt.type,at((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ht.type,at((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Et())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Nt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(ft.type,at((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(yt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("HANDSHAKE_FAILURE");jt.onEnter((function(e){return pt({category:"PNNetworkIssuesCategory"})})),jt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),jt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),jt.on(yt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ye("STOPPED");Rt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(yt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Ct.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(gt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ht(e)})),xt.onExit((function(){return ht.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),xt.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Et.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[pt({category:"PNDisconnectedCategory"})])})),xt.on(gt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])})),xt.on(vt.type,(function(e){return It.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt({category:"PNConnectedCategory"})})),It.onEnter((function(e){return ct(e.channels,e.groups,e.cursor)})),It.onExit((function(){return ct.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[lt(t.payload.events)])})),It.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(gt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ft(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return jt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Dt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return ut(e.channels,e.groups)})),Gt.onExit((function(){return ut.cancel})),Gt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(dt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(yt())},e.prototype.disconnect=function(){this.engine.transition(gt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new g({setup:e});this._config=o;var c=new T({config:o}),l=e.cryptography;r.init(o);var p=new L(o,i);this._tokenManager=p;var h=new U({maximumSamplesCount:6e4});this._telemetryManager=h;var f={config:o,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return l.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return l.decryptFile(e,n,t.File)};var d=W.bind(this,f,Je),y=W.bind(this,f,ie),v=W.bind(this,f,se),b=W.bind(this,f,ue),m=W.bind(this,f,We),_=new F;if(this._listenerManager=_,this.iAmHere=W.bind(this,f,se),this.iAmAway=W.bind(this,f,ie),this.setPresenceState=W.bind(this,f,ue),this.handshake=W.bind(this,f,Xe),this.receiveMessages=W.bind(this,f,$e),!0===o.enableSubscribeBeta){var O=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return 2*e},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return t<2},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;_.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){_.announceStatus(e)}});this.subscribe=O.subscribe.bind(O),this.unsubscribe=O.unsubscribe.bind(O),this.eventEngine=O}else{var P=new j({timeEndpoint:d,leaveEndpoint:y,heartbeatEndpoint:v,setStateEndpoint:b,subscribeEndpoint:m,crypto:f.crypto,config:f.config,listenerManager:_,getFileUrl:function(e){return ve(f,e)}});this.subscribe=P.adaptSubscribeChange.bind(P),this.unsubscribe=P.adaptUnsubscribeChange.bind(P),this.disconnect=P.disconnect.bind(P),this.reconnect=P.reconnect.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.setState=P.adaptStateChange.bind(P),this.presence=P.adaptPresenceChange.bind(P),this.destroy=function(e){P.unsubscribeAll(e),P.disconnect()}}this.addListener=_.addListener.bind(_),this.removeListener=_.removeListener.bind(_),this.removeAllListeners=_.removeAllListeners.bind(_),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:W.bind(this,f,Y),listChannels:W.bind(this,f,Z),addChannels:W.bind(this,f,X),removeChannels:W.bind(this,f,$),deleteGroup:W.bind(this,f,Q)},this.push={addChannels:W.bind(this,f,ee),removeChannels:W.bind(this,f,te),deleteDevice:W.bind(this,f,re),listChannels:W.bind(this,f,ne)},this.hereNow=W.bind(this,f,ce),this.whereNow=W.bind(this,f,oe),this.getState=W.bind(this,f,ae),this.grant=W.bind(this,f,Re),this.grantToken=W.bind(this,f,De),this.audit=W.bind(this,f,je),this.revokeToken=W.bind(this,f,Ge),this.publish=W.bind(this,f,Fe),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=W.bind(this,f,Le),this.history=W.bind(this,f,He),this.deleteMessages=W.bind(this,f,qe),this.messageCounts=W.bind(this,f,ze),this.fetchMessages=W.bind(this,f,Ve),this.addMessageAction=W.bind(this,f,le),this.removeMessageAction=W.bind(this,f,pe),this.getMessageActions=W.bind(this,f,he),this.listFiles=W.bind(this,f,fe);var S=W.bind(this,f,de);this.publishFile=W.bind(this,f,ge),this.sendFile=ye({generateUploadUrl:S,publishFile:this.publishFile,modules:f}),this.getFileUrl=function(e){return ve(f,e)},this.downloadFile=W.bind(this,f,be),this.deleteFile=W.bind(this,f,me),this.objects={getAllUUIDMetadata:W.bind(this,f,_e),getUUIDMetadata:W.bind(this,f,Oe),setUUIDMetadata:W.bind(this,f,Pe),removeUUIDMetadata:W.bind(this,f,Se),getAllChannelMetadata:W.bind(this,f,we),getChannelMetadata:W.bind(this,f,Te),setChannelMetadata:W.bind(this,f,ke),removeChannelMetadata:W.bind(this,f,Ne),getChannelMembers:W.bind(this,f,Ee),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function Ht(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?Ht(s):s})),n}var qt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),zt={exports:{}},Vt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function rn(e,t,n,r){void 0===r&&(r=Yt());var i,o=on(e,"",0,[],void 0,0,r)||e;try{i=0===Qt.length?JSON.stringify(o,t,n):JSON.stringify(o,sn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==$t.length;){var s=$t.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function on(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void en(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void en(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(fn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===pn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=dn[u]:u<2048?s+=dn[192|u>>6]+dn[128|63&u]:u<55296||u>=57344?s+=dn[224|u>>12]+dn[128|u>>6&63]+dn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=dn[240|u>>18]+dn[128|u>>12&63]+dn[128|u>>6&63]+dn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(fn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(On(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},xn=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&An.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},In={formats:ln,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||Cn.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Mn(l)?[l]:l),An.call(r,c)?r[c]=Cn.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Dn(e){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dn(e)}var Gn=function(e){return null!==e&&"object"===Dn(e)};function Kn(e){return Kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kn(e)}var Fn=Gn,Ln=Bn;function Bn(e){if(e)return function(e){for(var t in Bn.prototype)Object.prototype.hasOwnProperty.call(Bn.prototype,t)&&(e[t]=Bn.prototype[t]);return e}(e)}Bn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Bn.prototype.parse=function(e){return this._parser=e,this},Bn.prototype.responseType=function(e){return this._responseType=e,this},Bn.prototype.serialize=function(e){return this._serializer=e,this},Bn.prototype.timeout=function(e){if(!e||"object"!==Kn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Bn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var Hn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),qn=new Set([408,413,429,500,502,503,504,521,522,524]);Bn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&qn.has(t.status))return!0;if(e){if(e.code&&Hn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Bn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Bn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Bn.prototype.catch=function(e){return this.then(void 0,e)},Bn.prototype.use=function(e){return e(this),this},Bn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Bn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Bn.prototype.get=function(e){return this._header[e.toLowerCase()]},Bn.prototype.getHeader=Bn.prototype.get,Bn.prototype.set=function(e,t){if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Bn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Bn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Fn(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Bn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Bn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Bn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Bn.prototype.redirects=function(e){return this._maxRedirects=e,this},Bn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Bn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Bn.prototype.send=function(e){var t=Fn(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Fn(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Bn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Bn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Bn.prototype._appendQueryString=function(){console.warn("Unsupported")},Bn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Bn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var zn={};function Vn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Jn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(zt,zt.exports);var tr=zt.exports;function nr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function rr(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(nr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function ir(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=tr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function or(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function sr(e,t,n){var r=tr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function ar(e,t,n,r){var i=tr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function ur(e,t,n,r){var i=tr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return rr.call(this,i,n,r)}function cr(e,t,n){var r=tr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return rr.call(this,r,t,n)}function lr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var pr,hr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=lr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=lr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),fr=(pr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),pr.supportsFile="undefined"!=typeof File,pr.supportsBlob="undefined"!=typeof Blob,pr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,pr.supportsBuffer=!1,pr.supportsStream=!1,pr.supportsString=!0,pr.supportsEncryptFile=!0,pr.supportsFileUri=!1,pr);function dr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var gr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Bt({del:cr,get:sr,post:ar,patch:ur,sendBeacon:dr,getfile:or,postfile:ir}),t.cbor=new qt((function(e){return Ht(p.decode(e))}),y),t.PubNubFile=fr,t.cryptography=new hr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Lt);return gr})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 i(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=i,r.VERSION=t,e.uuid=r,e.isUUID=i}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var f=h.exports,d=function(){return f.uuid?f.uuid():f()},g=function(){function e(e){var t,n,r,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(d()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.setCipherKey(i.cipherKey),this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableSubscribeBeta=null!==(r=i.enableSubscribeBeta)&&void 0!==r&&r,this.reconnectionConfiguration=i.reconnectionConfiguration||{reconnectionPolicy:"None"},"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e){return this.cipherKey=e,this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.3"},e.prototype.setReconnectionConfiguration=function(e,t){this.reconnectionConfiguration=n(n({},config.reconnectionConfiguration),{reconnectionPolicy:e,maximumReconnectionRetries:t})},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],N=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,N,k,a,12,c[1]),k=t(k,T,w,N,l,17,c[2]),N=t(N,k,T,w,p,22,c[3]);w=t(w,N,k,T,h,7,c[4]),T=t(T,w,N,k,f,12,c[5]),k=t(k,T,w,N,d,17,c[6]),N=t(N,k,T,w,g,22,c[7]),w=t(w,N,k,T,y,7,c[8]),T=t(T,w,N,k,v,12,c[9]),k=t(k,T,w,N,b,17,c[10]),N=t(N,k,T,w,m,22,c[11]),w=t(w,N,k,T,_,7,c[12]),T=t(T,w,N,k,O,12,c[13]),k=t(k,T,w,N,P,17,c[14]),w=n(w,N=t(N,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,N,k,d,9,c[17]),k=n(k,T,w,N,m,14,c[18]),N=n(N,k,T,w,u,20,c[19]),w=n(w,N,k,T,f,5,c[20]),T=n(T,w,N,k,b,9,c[21]),k=n(k,T,w,N,S,14,c[22]),N=n(N,k,T,w,h,20,c[23]),w=n(w,N,k,T,v,5,c[24]),T=n(T,w,N,k,P,9,c[25]),k=n(k,T,w,N,p,14,c[26]),N=n(N,k,T,w,y,20,c[27]),w=n(w,N,k,T,O,5,c[28]),T=n(T,w,N,k,l,9,c[29]),k=n(k,T,w,N,g,14,c[30]),w=r(w,N=n(N,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,N,k,y,11,c[33]),k=r(k,T,w,N,m,16,c[34]),N=r(N,k,T,w,P,23,c[35]),w=r(w,N,k,T,a,4,c[36]),T=r(T,w,N,k,h,11,c[37]),k=r(k,T,w,N,g,16,c[38]),N=r(N,k,T,w,b,23,c[39]),w=r(w,N,k,T,O,4,c[40]),T=r(T,w,N,k,u,11,c[41]),k=r(k,T,w,N,p,16,c[42]),N=r(N,k,T,w,d,23,c[43]),w=r(w,N,k,T,v,4,c[44]),T=r(T,w,N,k,_,11,c[45]),k=r(k,T,w,N,S,16,c[46]),w=i(w,N=r(N,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,N,k,g,10,c[49]),k=i(k,T,w,N,P,15,c[50]),N=i(N,k,T,w,f,21,c[51]),w=i(w,N,k,T,_,6,c[52]),T=i(T,w,N,k,p,10,c[53]),k=i(k,T,w,N,b,15,c[54]),N=i(N,k,T,w,a,21,c[55]),w=i(w,N,k,T,y,6,c[56]),T=i(T,w,N,k,S,10,c[57]),k=i(k,T,w,N,d,15,c[58]),N=i(N,k,T,w,O,21,c[59]),w=i(w,N,k,T,h,6,c[60]),T=i(T,w,N,k,m,10,c[61]),k=i(k,T,w,N,l,15,c[62]),N=i(N,k,T,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+N|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function E(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function C(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return C(e).map((function(t){return"".concat(t,"=").concat(E(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:E},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory"},R=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new N({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),j={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==j.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==j.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case j.PNPublishOperation:t="pub";break;case j.PNSignalOperation:t="sig";break;case j.PNHistoryOperation:case j.PNFetchMessagesOperation:case j.PNDeleteMessagesOperation:case j.PNMessageCounts:t="hist";break;case j.PNUnsubscribeOperation:case j.PNWhereNowOperation:case j.PNHereNowOperation:case j.PNHeartbeatOperation:case j.PNSetStateOperation:case j.PNGetStateOperation:t="pres";break;case j.PNAddChannelsToGroupOperation:case j.PNRemoveChannelsFromGroupOperation:case j.PNChannelGroupsOperation:case j.PNRemoveGroupOperation:case j.PNChannelsForGroupOperation:t="cg";break;case j.PNPushNotificationEnabledChannelsOperation:case j.PNRemoveAllPushNotificationsOperation:t="push";break;case j.PNCreateUserOperation:case j.PNUpdateUserOperation:case j.PNDeleteUserOperation:case j.PNGetUserOperation:case j.PNGetUsersOperation:case j.PNCreateSpaceOperation:case j.PNUpdateSpaceOperation:case j.PNDeleteSpaceOperation:case j.PNGetSpaceOperation:case j.PNGetSpacesOperation:case j.PNGetMembersOperation:case j.PNUpdateMembersOperation:case j.PNGetMembershipsOperation:case j.PNUpdateMembershipsOperation:t="obj";break;case j.PNAddMessageActionOperation:case j.PNRemoveMessageActionOperation:case j.PNGetMessageActionsOperation:t="msga";break;case j.PNAccessManagerGrant:case j.PNAccessManagerAudit:t="pam";break;case j.PNAccessManagerGrantToken:case j.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function X(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return j.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return j.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return j.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return j.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return j.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return j.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return j.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return j.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,T,k,N,E,C,A,M,R,j,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(E=(N=l).POSTFILE,C=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,E.apply(N,C.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,R=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,R.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(j=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(j,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},be={getOperation:function(){return j.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return j.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return j.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return j.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return j.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return j.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return j.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return j.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return j.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return j.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ce={getOperation:function(){return j.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return j.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return j.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Re=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var je=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return j.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return j.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return j.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return j.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return j.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return j.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return j.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return j.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var Xe=Object.freeze({__proto__:null,getOperation:function(){return j.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),We={getOperation:function(){return j.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return j.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(pt.type,at((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ht.type,at((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Et())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Nt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(ft.type,at((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(yt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ye("HANDSHAKE_FAILURE");Rt.onEnter((function(e){return pt({category:"PNNetworkIssuesCategory"})})),Rt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),Rt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Rt.on(yt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("STOPPED");jt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(yt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Ct.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ht(e)})),xt.onExit((function(){return ht.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),xt.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Et.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[pt({category:"PNDisconnectedCategory"})])})),xt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])})),xt.on(vt.type,(function(e){return It.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt({category:"PNConnectedCategory"})})),It.onEnter((function(e){return ct(e.channels,e.groups,e.cursor)})),It.onExit((function(){return ct.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[lt(t.payload.events)])})),It.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ft(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return Rt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Dt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return ut(e.channels,e.groups)})),Gt.onExit((function(){return ut.cancel})),Gt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:e.timetoken&&"0"!==e.timetoken?e.timetoken:t.payload.timetoken,region:t.payload.region}})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups,r=e.timetoken;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(dt(this.channels,this.groups,null!=r?r:"0"))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(yt())},e.prototype.disconnect=function(){this.engine.transition(gt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(){}return e.getDelay=function(e,t,n){var r=null!=n?n:5;switch(e.toUpperCase()){case"LINEAR":return t*r+1e3*Math.random();case"EXPONENTIAL":return 1e3*Math.trunc(Math.pow(2,t-1))+1e3*Math.random();default:throw new Error("invalid policy")}},e}(),Bt=function(){function e(e){var t,r=this,i=e.networking,o=e.cbor,c=new g({setup:e});this._config=c;var l=new T({config:c}),p=e.cryptography;i.init(c);var h=new L(c,o);this._tokenManager=h;var f=new U({maximumSamplesCount:6e4});this._telemetryManager=f;var d={config:c,networking:i,crypto:l,cryptography:p,tokenManager:h,telemetryManager:f,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,t){return p.encryptFile(e,t,r.File)},this.decryptFile=function(e,t){return p.decryptFile(e,t,r.File)};var y=X.bind(this,d,Je),v=X.bind(this,d,ie),b=X.bind(this,d,se),m=X.bind(this,d,ue),_=X.bind(this,d,Xe),O=new F;if(this._listenerManager=O,this.iAmHere=X.bind(this,d,se),this.iAmAway=X.bind(this,d,ie),this.setPresenceState=X.bind(this,d,ue),this.handshake=X.bind(this,d,We),this.receiveMessages=X.bind(this,d,$e),!0===c.enableSubscribeBeta){var P=d.config.reconnectionConfiguration.reconnectionPolicy,S=null!==(t=d.config.reconnectionConfiguration.maximumReconnectionRetries)&&void 0!==t?t:0,w=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return Lt.getDelay(P,S)},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return S>=t&&P&&"None"!=P},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;O.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){O.announceStatus(e)}});this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.unsubscribeAll=w.unsubscribeAll.bind(w),this.reconnect=w.reconnect.bind(w),this.disconnect=w.disconnect.bind(w),this.eventEngine=w}else{var k=new R({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:m,subscribeEndpoint:_,crypto:d.crypto,config:d.config,listenerManager:O,getFileUrl:function(e){return ve(d,e)}});this.subscribe=k.adaptSubscribeChange.bind(k),this.unsubscribe=k.adaptUnsubscribeChange.bind(k),this.disconnect=k.disconnect.bind(k),this.reconnect=k.reconnect.bind(k),this.unsubscribeAll=k.unsubscribeAll.bind(k),this.getSubscribedChannels=k.getSubscribedChannels.bind(k),this.getSubscribedChannelGroups=k.getSubscribedChannelGroups.bind(k),this.setState=k.adaptStateChange.bind(k),this.presence=k.adaptPresenceChange.bind(k),this.destroy=function(e){k.unsubscribeAll(e),k.disconnect()}}this.addListener=O.addListener.bind(O),this.removeListener=O.removeListener.bind(O),this.removeAllListeners=O.removeAllListeners.bind(O),this.parseToken=h.parseToken.bind(h),this.setToken=h.setToken.bind(h),this.getToken=h.getToken.bind(h),this.channelGroups={listGroups:X.bind(this,d,Y),listChannels:X.bind(this,d,Z),addChannels:X.bind(this,d,W),removeChannels:X.bind(this,d,$),deleteGroup:X.bind(this,d,Q)},this.push={addChannels:X.bind(this,d,ee),removeChannels:X.bind(this,d,te),deleteDevice:X.bind(this,d,re),listChannels:X.bind(this,d,ne)},this.hereNow=X.bind(this,d,ce),this.whereNow=X.bind(this,d,oe),this.getState=X.bind(this,d,ae),this.grant=X.bind(this,d,je),this.grantToken=X.bind(this,d,De),this.audit=X.bind(this,d,Re),this.revokeToken=X.bind(this,d,Ge),this.publish=X.bind(this,d,Fe),this.fire=function(e,t){return e.replicate=!1,e.storeInHistory=!1,r.publish(e,t)},this.signal=X.bind(this,d,Le),this.history=X.bind(this,d,He),this.deleteMessages=X.bind(this,d,qe),this.messageCounts=X.bind(this,d,ze),this.fetchMessages=X.bind(this,d,Ve),this.addMessageAction=X.bind(this,d,le),this.removeMessageAction=X.bind(this,d,pe),this.getMessageActions=X.bind(this,d,he),this.listFiles=X.bind(this,d,fe);var N=X.bind(this,d,de);this.publishFile=X.bind(this,d,ge),this.sendFile=ye({generateUploadUrl:N,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return ve(d,e)},this.downloadFile=X.bind(this,d,be),this.deleteFile=X.bind(this,d,me),this.objects={getAllUUIDMetadata:X.bind(this,d,_e),getUUIDMetadata:X.bind(this,d,Oe),setUUIDMetadata:X.bind(this,d,Pe),removeUUIDMetadata:X.bind(this,d,Se),getAllChannelMetadata:X.bind(this,d,we),getChannelMetadata:X.bind(this,d,Te),setChannelMetadata:X.bind(this,d,ke),removeChannelMetadata:X.bind(this,d,Ne),getChannelMembers:X.bind(this,d,Ee),setChannelMembers:function(e){for(var t=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function qt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?qt(s):s})),n}var zt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),Vt={exports:{}},Jt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function on(e,t,n,r){void 0===r&&(r=Zt());var i,o=sn(e,"",0,[],void 0,0,r)||e;try{i=0===Yt.length?JSON.stringify(o,t,n):JSON.stringify(o,an(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Qt.length;){var s=Qt.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function sn(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(dn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===hn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=gn[u]:u<2048?s+=gn[192|u>>6]+gn[128|63&u]:u<55296||u>=57344?s+=gn[224|u>>12]+gn[128|u>>6&63]+gn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=gn[240|u>>18]+gn[128|u>>12&63]+gn[128|u>>6&63]+gn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(dn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(Pn(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},In=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&Mn.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},Dn={formats:pn,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||An.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Rn(l)?[l]:l),Mn.call(r,c)?r[c]=An.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Gn(e){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gn(e)}var Kn=function(e){return null!==e&&"object"===Gn(e)};function Fn(e){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fn(e)}var Ln=Kn,Bn=Hn;function Hn(e){if(e)return function(e){for(var t in Hn.prototype)Object.prototype.hasOwnProperty.call(Hn.prototype,t)&&(e[t]=Hn.prototype[t]);return e}(e)}Hn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Hn.prototype.parse=function(e){return this._parser=e,this},Hn.prototype.responseType=function(e){return this._responseType=e,this},Hn.prototype.serialize=function(e){return this._serializer=e,this},Hn.prototype.timeout=function(e){if(!e||"object"!==Fn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Hn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var qn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),zn=new Set([408,413,429,500,502,503,504,521,522,524]);Hn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&zn.has(t.status))return!0;if(e){if(e.code&&qn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Hn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Hn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Hn.prototype.catch=function(e){return this.then(void 0,e)},Hn.prototype.use=function(e){return e(this),this},Hn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Hn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Hn.prototype.get=function(e){return this._header[e.toLowerCase()]},Hn.prototype.getHeader=Hn.prototype.get,Hn.prototype.set=function(e,t){if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Hn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Hn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Hn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Hn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Hn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Hn.prototype.redirects=function(e){return this._maxRedirects=e,this},Hn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Hn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Hn.prototype.send=function(e){var t=Ln(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Ln(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Hn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Hn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Hn.prototype._appendQueryString=function(){console.warn("Unsupported")},Hn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Hn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var Vn={};function Jn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Xn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(Vt,Vt.exports);var nr=Vt.exports;function rr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function ir(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(rr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function or(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=nr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function sr(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ar(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ur(e,t,n,r){var i=nr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function cr(e,t,n,r){var i=nr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function lr(e,t,n){var r=nr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function pr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var hr,fr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=pr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=pr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),dr=(hr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),hr.supportsFile="undefined"!=typeof File,hr.supportsBlob="undefined"!=typeof Blob,hr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,hr.supportsBuffer=!1,hr.supportsStream=!1,hr.supportsString=!0,hr.supportsEncryptFile=!0,hr.supportsFileUri=!1,hr);function gr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var yr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:lr,get:ar,post:ur,patch:cr,sendBeacon:gr,getfile:sr,postfile:or}),t.cbor=new zt((function(e){return qt(p.decode(e))}),y),t.PubNubFile=dr,t.cryptography=new fr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Bt);return yr})); diff --git a/lib/core/components/config.js b/lib/core/components/config.js index 13e65b07e..0ef3a179c 100644 --- a/lib/core/components/config.js +++ b/lib/core/components/config.js @@ -1,6 +1,17 @@ "use strict"; /* */ /* global location */ +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -42,6 +53,8 @@ var default_1 = /** @class */ (function () { this.useRandomIVs = (_c = setup.useRandomIVs) !== null && _c !== void 0 ? _c : true; // flag for beta subscribe feature enablement this.enableSubscribeBeta = (_d = setup.enableSubscribeBeta) !== null && _d !== void 0 ? _d : false; + // reconnection configuration settings to apply reconnection settings in subscription + this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; // if location config exist and we are in https, force secure to true. if (typeof location !== 'undefined' && location.protocol === 'https:') { this.secure = true; @@ -169,7 +182,10 @@ var default_1 = /** @class */ (function () { return this; }; default_1.prototype.getVersion = function () { - return '7.2.2'; + return '7.2.3'; + }; + default_1.prototype.setReconnectionConfiguration = function (reconnectionPolicy, maximumReconnectionRetries) { + this.reconnectionConfiguration = __assign(__assign({}, config.reconnectionConfiguration), { reconnectionPolicy: reconnectionPolicy, maximumReconnectionRetries: maximumReconnectionRetries }); }; default_1.prototype._addPnsdkSuffix = function (name, suffix) { this._PNSDKSuffix[name] = suffix; diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index a2b579ac4..657a1c46c 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -140,10 +140,12 @@ var operations_1 = __importDefault(require("./constants/operations")); var categories_1 = __importDefault(require("./constants/categories")); var uuid_1 = __importDefault(require("./components/uuid")); var event_engine_1 = require("../event-engine"); +var reconnectionDelay_1 = require("../event-engine/core/reconnectionDelay"); var default_1 = /** @class */ (function () { // function default_1(setup) { var _this = this; + var _a; var networking = setup.networking, cbor = setup.cbor; var config = new config_1.default({ setup: setup }); this._config = config; @@ -182,12 +184,14 @@ var default_1 = /** @class */ (function () { this.handshake = endpoint_1.default.bind(this, modules, handshake_1.default); this.receiveMessages = endpoint_1.default.bind(this, modules, receiveMessages_1.default); if (config.enableSubscribeBeta === true) { + var policy_1 = modules.config.reconnectionConfiguration.reconnectionPolicy; + var maxRetries_1 = (_a = modules.config.reconnectionConfiguration.maximumReconnectionRetries) !== null && _a !== void 0 ? _a : 0; var eventEngine = new event_engine_1.EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return attempts * 2; }, + getRetryDelay: function (attempts) { return reconnectionDelay_1.ReconnectionDelay.getDelay(policy_1, maxRetries_1); }, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (error, attempts) { return attempts < 2; }, + shouldRetry: function (_, attempts) { return maxRetries_1 >= attempts && policy_1 && policy_1 != 'None'; }, emitEvents: function (events) { var e_1, _a; try { @@ -210,6 +214,9 @@ var default_1 = /** @class */ (function () { }); this.subscribe = eventEngine.subscribe.bind(eventEngine); this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); + this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); + this.reconnect = eventEngine.reconnect.bind(eventEngine); + this.disconnect = eventEngine.disconnect.bind(eventEngine); this.eventEngine = eventEngine; } else { diff --git a/lib/event-engine/core/reconnectionDelay.js b/lib/event-engine/core/reconnectionDelay.js new file mode 100644 index 000000000..15d0ae9ee --- /dev/null +++ b/lib/event-engine/core/reconnectionDelay.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ReconnectionDelay = void 0; +var ReconnectionDelay = /** @class */ (function () { + function ReconnectionDelay() { + } + ReconnectionDelay.getDelay = function (policy, attempts, backoff) { + var backoffValue = backoff !== null && backoff !== void 0 ? backoff : 5; + switch (policy.toUpperCase()) { + case 'LINEAR': + return attempts * backoffValue + Math.random() * 1000; + case 'EXPONENTIAL': + return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; + default: + throw new Error('invalid policy'); + } + }; + return ReconnectionDelay; +}()); +exports.ReconnectionDelay = ReconnectionDelay; diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index ee60fdc64..480d0a945 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -2,9 +2,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.reconnectingRetry = exports.reconnectingGiveup = exports.reconnectingFailure = exports.reconnectingSuccess = exports.receivingFailure = exports.receivingSuccess = exports.handshakingReconnectingRetry = exports.handshakingReconnectingGiveup = exports.handshakingReconnectingFailure = exports.handshakingReconnectingSuccess = exports.handshakingFailure = exports.handshakingSuccess = exports.restore = exports.reconnect = exports.disconnect = exports.subscriptionChange = void 0; var core_1 = require("./core"); -exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', function (channels, groups) { return ({ +exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ channels: channels, groups: groups, + timetoken: timetoken }); }); exports.disconnect = (0, core_1.createEvent)('DISCONNECT', function () { return ({}); }); exports.reconnect = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); diff --git a/lib/event-engine/index.js b/lib/event-engine/index.js index a8dc852b4..73948e0bd 100644 --- a/lib/event-engine/index.js +++ b/lib/event-engine/index.js @@ -75,10 +75,10 @@ var EventEngine = /** @class */ (function () { configurable: true }); EventEngine.prototype.subscribe = function (_a) { - var channels = _a.channels, groups = _a.groups; + var channels = _a.channels, groups = _a.groups, timetoken = _a.timetoken; this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); - this.engine.transition(events.subscriptionChange(this.channels, this.groups)); + this.engine.transition(events.subscriptionChange(this.channels, this.groups, timetoken !== null && timetoken !== void 0 ? timetoken : '0')); }; EventEngine.prototype.unsubscribe = function (_a) { var channels = _a.channels, groups = _a.groups; diff --git a/lib/event-engine/states/handshaking.js b/lib/event-engine/states/handshaking.js index 8fd804dad..a3830efea 100644 --- a/lib/event-engine/states/handshaking.js +++ b/lib/event-engine/states/handshaking.js @@ -32,7 +32,10 @@ exports.HandshakingState.on(events_1.handshakingSuccess.type, function (context, return receiving_1.ReceivingState.with({ channels: context.channels, groups: context.groups, - cursor: event.payload, + cursor: { + timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + region: event.payload.region, + }, }); }); exports.HandshakingState.on(events_1.handshakingFailure.type, function (context, event) { diff --git a/lib/event-engine/states/unsubscribed.js b/lib/event-engine/states/unsubscribed.js index 905ea4e73..4f1523a48 100644 --- a/lib/event-engine/states/unsubscribed.js +++ b/lib/event-engine/states/unsubscribed.js @@ -6,5 +6,5 @@ var events_1 = require("../events"); var handshaking_1 = require("./handshaking"); exports.UnsubscribedState = new state_1.State('UNSUBSCRIBED'); exports.UnsubscribedState.on(events_1.subscriptionChange.type, function (_, event) { - return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, timetoken: event.payload.timetoken }); }); diff --git a/src/core/components/config.js b/src/core/components/config.js index 81d257061..3422e0d1f 100644 --- a/src/core/components/config.js +++ b/src/core/components/config.js @@ -74,6 +74,10 @@ export default class { // when there changes in the networking autoNetworkDetection; + // to configure reconnection policy and maximumReconnectionRetry values + // default reconnection policy is PNReconnectionPolicy.NONE and maximumReconnectionRetry value is 0 + reconnectionConfiguration; + // alert when a heartbeat works out. announceSuccessfulHeartbeats; @@ -181,6 +185,9 @@ export default class { // flag for beta subscribe feature enablement this.enableSubscribeBeta = setup.enableSubscribeBeta ?? false; + // reconnection configuration settings to apply reconnection settings in subscription + this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy : 'None'}; + // if location config exist and we are in https, force secure to true. if (typeof location !== 'undefined' && location.protocol === 'https:') { this.secure = true; @@ -342,6 +349,14 @@ export default class { return '7.2.3'; } + setReconnectionConfiguration(reconnectionPolicy, maximumReconnectionRetries) { + this.reconnectionConfiguration = { + ...config.reconnectionConfiguration, + reconnectionPolicy: reconnectionPolicy, + maximumReconnectionRetries: maximumReconnectionRetries, + }; + } + _addPnsdkSuffix(name, suffix) { this._PNSDKSuffix[name] = suffix; } diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 73ed9b474..9688c379c 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -90,6 +90,7 @@ import CATEGORIES from './constants/categories'; import uuidGenerator from './components/uuid'; import { EventEngine } from '../event-engine'; +import { ReconnectionDelay } from '../event-engine/core/reconnectionDelay'; export default class { _config; @@ -320,12 +321,14 @@ export default class { this.receiveMessages = endpointCreator.bind(this, modules, receiveMessagesConfig); if (config.enableSubscribeBeta === true) { + let policy = modules.config.reconnectionConfiguration.reconnectionPolicy; + let maxRetries = modules.config.reconnectionConfiguration.maximumReconnectionRetries ?? 0; const eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: (attempts) => attempts * 2, + getRetryDelay: (attempts) => ReconnectionDelay.getDelay(policy, maxRetries), delay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), - shouldRetry: (error, attempts) => attempts < 2, + shouldRetry: (_, attempts) => maxRetries >= attempts && policy && policy != 'None', emitEvents: (events) => { for (const event of events) { listenerManager.announceMessage(event); @@ -338,6 +341,9 @@ export default class { this.subscribe = eventEngine.subscribe.bind(eventEngine); this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); + this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); + this.reconnect = eventEngine.reconnect.bind(eventEngine); + this.disconnect = eventEngine.disconnect.bind(eventEngine); this.eventEngine = eventEngine; } else { diff --git a/src/event-engine/core/reconnectionDelay.ts b/src/event-engine/core/reconnectionDelay.ts new file mode 100644 index 000000000..6133aaf97 --- /dev/null +++ b/src/event-engine/core/reconnectionDelay.ts @@ -0,0 +1,13 @@ +export class ReconnectionDelay { + static getDelay(policy: string, attempts: number, backoff?: number): number { + let backoffValue = backoff ?? 5; + switch (policy.toUpperCase()) { + case 'LINEAR': + return attempts * backoffValue + Math.random() * 1000; + case 'EXPONENTIAL': + return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; + default: + throw new Error('invalid policy'); + } + } +} diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 1161e1f0a..34945a335 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -2,9 +2,10 @@ import { PubNubError } from '../core/components/endpoint'; import { Cursor } from '../models/Cursor'; import { createEvent, MapOf } from './core'; -export const subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', (channels: string[], groups: string[]) => ({ +export const subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', (channels: string[], groups: string[], timetoken?: string) => ({ channels, groups, + timetoken })); export const disconnect = createEvent('DISCONNECT', () => ({})); diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index 76cc28991..19ccc7c72 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -30,11 +30,11 @@ export class EventEngine { channels: string[] = []; groups: string[] = []; - subscribe({ channels, groups }: { channels?: string[]; groups?: string[] }) { + subscribe({ channels, groups, timetoken }: { channels?: string[]; groups?: string[]; timetoken?: string }) { this.channels = [...this.channels, ...(channels ?? [])]; this.groups = [...this.groups, ...(groups ?? [])]; - this.engine.transition(events.subscriptionChange(this.channels, this.groups)); + this.engine.transition(events.subscriptionChange(this.channels, this.groups, timetoken?? '0')); } unsubscribe({ channels, groups }: { channels?: string[]; groups?: string[] }) { diff --git a/src/event-engine/states/handshaking.ts b/src/event-engine/states/handshaking.ts index ce28edada..20bf7a400 100644 --- a/src/event-engine/states/handshaking.ts +++ b/src/event-engine/states/handshaking.ts @@ -9,6 +9,7 @@ import { UnsubscribedState } from './unsubscribed'; export type HandshakingStateContext = { channels: string[]; groups: string[]; + timetoken?: string; }; export const HandshakingState = new State('HANDSHAKING'); @@ -28,7 +29,10 @@ HandshakingState.on(handshakingSuccess.type, (context, event) => ReceivingState.with({ channels: context.channels, groups: context.groups, - cursor: event.payload, + cursor: { + timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + region: event.payload.region, + }, }), ); diff --git a/src/event-engine/states/unsubscribed.ts b/src/event-engine/states/unsubscribed.ts index efb0aa7e2..14f368eb1 100644 --- a/src/event-engine/states/unsubscribed.ts +++ b/src/event-engine/states/unsubscribed.ts @@ -6,5 +6,5 @@ import { HandshakingState } from './handshaking'; export const UnsubscribedState = new State('UNSUBSCRIBED'); UnsubscribedState.on(subscriptionChange.type, (_, event) => - HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), + HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, timetoken: event.payload.timetoken }), ); diff --git a/test/unit/event_engine.test.ts b/test/unit/event_engine.test.ts index 89a572aa7..625508f2d 100644 --- a/test/unit/event_engine.test.ts +++ b/test/unit/event_engine.test.ts @@ -34,6 +34,7 @@ describe('EventEngine', () => { afterEach(() => { unsub(); + pubnub.destroy(); }); function forEvent(eventLabel: string, timeout?: number) { From 1c376a9a785a5bf7c16be6eaf256a6950a9a0961 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 11 Jul 2023 13:01:23 +0530 Subject: [PATCH 14/63] lint/prettier --- src/core/components/config.js | 2 +- src/event-engine/core/reconnectionDelay.ts | 2 +- src/event-engine/events.ts | 13 ++++++++----- src/event-engine/index.ts | 2 +- src/event-engine/states/unsubscribed.ts | 6 +++++- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/core/components/config.js b/src/core/components/config.js index 3422e0d1f..b6a6bf3c3 100644 --- a/src/core/components/config.js +++ b/src/core/components/config.js @@ -186,7 +186,7 @@ export default class { this.enableSubscribeBeta = setup.enableSubscribeBeta ?? false; // reconnection configuration settings to apply reconnection settings in subscription - this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy : 'None'}; + this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; // if location config exist and we are in https, force secure to true. if (typeof location !== 'undefined' && location.protocol === 'https:') { diff --git a/src/event-engine/core/reconnectionDelay.ts b/src/event-engine/core/reconnectionDelay.ts index 6133aaf97..3c34bddcf 100644 --- a/src/event-engine/core/reconnectionDelay.ts +++ b/src/event-engine/core/reconnectionDelay.ts @@ -1,6 +1,6 @@ export class ReconnectionDelay { static getDelay(policy: string, attempts: number, backoff?: number): number { - let backoffValue = backoff ?? 5; + const backoffValue = backoff ?? 5; switch (policy.toUpperCase()) { case 'LINEAR': return attempts * backoffValue + Math.random() * 1000; diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 34945a335..c95a4c9e2 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -2,11 +2,14 @@ import { PubNubError } from '../core/components/endpoint'; import { Cursor } from '../models/Cursor'; import { createEvent, MapOf } from './core'; -export const subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', (channels: string[], groups: string[], timetoken?: string) => ({ - channels, - groups, - timetoken -})); +export const subscriptionChange = createEvent( + 'SUBSCRIPTION_CHANGED', + (channels: string[], groups: string[], timetoken?: string) => ({ + channels, + groups, + timetoken, + }), +); export const disconnect = createEvent('DISCONNECT', () => ({})); export const reconnect = createEvent('RECONNECT', () => ({})); diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index 19ccc7c72..4bb15948a 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -34,7 +34,7 @@ export class EventEngine { this.channels = [...this.channels, ...(channels ?? [])]; this.groups = [...this.groups, ...(groups ?? [])]; - this.engine.transition(events.subscriptionChange(this.channels, this.groups, timetoken?? '0')); + this.engine.transition(events.subscriptionChange(this.channels, this.groups, timetoken ?? '0')); } unsubscribe({ channels, groups }: { channels?: string[]; groups?: string[] }) { diff --git a/src/event-engine/states/unsubscribed.ts b/src/event-engine/states/unsubscribed.ts index 14f368eb1..bebc046d9 100644 --- a/src/event-engine/states/unsubscribed.ts +++ b/src/event-engine/states/unsubscribed.ts @@ -6,5 +6,9 @@ import { HandshakingState } from './handshaking'; export const UnsubscribedState = new State('UNSUBSCRIBED'); UnsubscribedState.on(subscriptionChange.type, (_, event) => - HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, timetoken: event.payload.timetoken }), + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }), ); From 09d77084b44cce5658b104b6abb3c4103e8d32b8 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 11 Jul 2023 13:11:37 +0530 Subject: [PATCH 15/63] fix: test. destroy() not required --- test/unit/event_engine.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unit/event_engine.test.ts b/test/unit/event_engine.test.ts index d94204e82..de3b868c0 100644 --- a/test/unit/event_engine.test.ts +++ b/test/unit/event_engine.test.ts @@ -34,7 +34,6 @@ describe('EventEngine', () => { afterEach(() => { unsub(); - pubnub.destroy(); }); function forEvent(eventLabel: string, timeout?: number) { From 0a2e39171c8e74be1cf47eddbc5d3821d8c630b8 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 11 Jul 2023 15:05:07 +0530 Subject: [PATCH 16/63] fix: naming convention and removed unnecessary effect dispatch --- dist/web/pubnub.js | 22582 +++++++++++----------- dist/web/pubnub.min.js | 2 +- lib/core/pubnub-common.js | 4 +- lib/event-engine/events.js | 6 +- lib/event-engine/states/unsubscribed.js | 6 +- src/core/pubnub-common.js | 4 +- src/event-engine/events.ts | 4 +- src/event-engine/states/receiving.ts | 1 - 8 files changed, 11308 insertions(+), 11301 deletions(-) diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index 0cebcdae3..1a172524e 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -1,9 +1,9 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.PubNub = factory()); -})(this, (function () { 'use strict'; - +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.PubNub = factory()); +})(this, (function () { 'use strict'; + /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -133,12 +133,12 @@ } } return to.concat(ar || Array.prototype.slice.call(from)); - } - - var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - - var cbor = {exports: {}}; - + } + + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + var cbor = {exports: {}}; + /* * The MIT License (MIT) * @@ -161,9 +161,9 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. - */ - - (function (module) { + */ + + (function (module) { (function(global, undefined$1) {var POW_2_24 = Math.pow(2, -24), POW_2_32 = Math.pow(2, 32), POW_2_53 = Math.pow(2, 53); @@ -544,11311 +544,11315 @@ else if (!global.CBOR) global.CBOR = obj; - })(commonjsGlobal); - }(cbor)); + })(commonjsGlobal); + }(cbor)); + + var CborReader = cbor.exports; + + var uuid = {exports: {}}; + + /*! lil-uuid - v0.1 - MIT License - https://github.com/lil-js/uuid */ + + (function (module, exports) { + (function (root, factory) { + { + factory(exports); + if (module !== null) { + module.exports = exports.uuid; + } + } + }(commonjsGlobal, function (exports) { + var VERSION = '0.1.0'; + var uuidRegex = { + '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 uuid() { + var uuid = '', i, random; + for (i = 0; i < 32; i++) { + random = Math.random() * 16 | 0; + if (i === 8 || i === 12 || i === 16 || i === 20) uuid += '-'; + uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16); + } + return uuid + } + + function isUUID(str, version) { + var pattern = uuidRegex[version || 'all']; + return pattern && pattern.test(str) || false + } + + uuid.isUUID = isUUID; + uuid.VERSION = VERSION; + + exports.uuid = uuid; + exports.isUUID = isUUID; + })); + }(uuid, uuid.exports)); + + var uuidGenerator$1 = uuid.exports; + + var uuidGenerator = { + createUUID: function () { + if (uuidGenerator$1.uuid) { + return uuidGenerator$1.uuid(); + } + return uuidGenerator$1(); + }, + }; + + /* */ + var PRESENCE_TIMEOUT_MINIMUM = 20; + var PRESENCE_TIMEOUT_DEFAULT = 300; + var makeDefaultOrigins = function () { return Array.from({ length: 20 }, function (_, i) { return "ps".concat(i + 1, ".pndsn.com"); }); }; + var default_1$b = /** @class */ (function () { + function default_1(_a) { + var setup = _a.setup; + var _b, _c, _d; + this._PNSDKSuffix = {}; + this.instanceId = "pn-".concat(uuidGenerator.createUUID()); + this.secretKey = setup.secretKey || setup.secret_key; + this.subscribeKey = setup.subscribeKey || setup.subscribe_key; + this.publishKey = setup.publishKey || setup.publish_key; + this.sdkName = setup.sdkName; + this.sdkFamily = setup.sdkFamily; + this.partnerId = setup.partnerId; + this.setAuthKey(setup.authKey); + this.setCipherKey(setup.cipherKey); + this.setFilterExpression(setup.filterExpression); + if (typeof setup.origin !== 'string' && !Array.isArray(setup.origin) && setup.origin !== undefined) { + throw new Error('Origin must be either undefined, a string or a list of strings.'); + } + this.origin = setup.origin || makeDefaultOrigins(); + this.secure = setup.ssl || false; + this.restore = setup.restore || false; + this.proxy = setup.proxy; + this.keepAlive = setup.keepAlive; + this.keepAliveSettings = setup.keepAliveSettings; + this.autoNetworkDetection = setup.autoNetworkDetection || false; + this.dedupeOnSubscribe = setup.dedupeOnSubscribe || false; + this.maximumCacheSize = setup.maximumCacheSize || 100; + this.customEncrypt = setup.customEncrypt; + this.customDecrypt = setup.customDecrypt; + this.fileUploadPublishRetryLimit = (_b = setup.fileUploadPublishRetryLimit) !== null && _b !== void 0 ? _b : 5; + this.useRandomIVs = (_c = setup.useRandomIVs) !== null && _c !== void 0 ? _c : true; + // flag for beta subscribe feature enablement + this.enableSubscribeBeta = (_d = setup.enableSubscribeBeta) !== null && _d !== void 0 ? _d : false; + // reconnection configuration settings to apply reconnection settings in subscription + this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; + // if location config exist and we are in https, force secure to true. + if (typeof location !== 'undefined' && location.protocol === 'https:') { + this.secure = true; + } + this.logVerbosity = setup.logVerbosity || false; + this.suppressLeaveEvents = setup.suppressLeaveEvents || false; + this.announceFailedHeartbeats = setup.announceFailedHeartbeats || true; + this.announceSuccessfulHeartbeats = setup.announceSuccessfulHeartbeats || false; + this.useInstanceId = setup.useInstanceId || false; + this.useRequestId = setup.useRequestId || false; + this.requestMessageCountThreshold = setup.requestMessageCountThreshold; + // set timeout to how long a transaction request will wait for the server (default 15 seconds) + this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000); + // set timeout to how long a subscribe event loop will run (default 310 seconds) + this.setSubscribeTimeout(setup.subscribeRequestTimeout || 310 * 1000); + // set config on beacon (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) usage + this.setSendBeaconConfig(setup.useSendBeacon || true); + // how long the SDK will report the client to be alive before issuing a timeout + if (setup.presenceTimeout) { + this.setPresenceTimeout(setup.presenceTimeout); + } + else { + this._presenceTimeout = PRESENCE_TIMEOUT_DEFAULT; + } + if (setup.heartbeatInterval != null) { + this.setHeartbeatInterval(setup.heartbeatInterval); + } + if (typeof setup.userId === 'string') { + if (typeof setup.uuid === 'string') { + throw new Error('Only one of the following configuration options has to be provided: `uuid` or `userId`'); + } + this.setUserId(setup.userId); + } + else { + if (typeof setup.uuid !== 'string') { + throw new Error('One of the following configuration options has to be provided: `uuid` or `userId`'); + } + this.setUUID(setup.uuid); + } + } + // exposed setters + default_1.prototype.getAuthKey = function () { + return this.authKey; + }; + default_1.prototype.setAuthKey = function (val) { + this.authKey = val; + return this; + }; + default_1.prototype.setCipherKey = function (val) { + this.cipherKey = val; + return this; + }; + default_1.prototype.getUUID = function () { + return this.UUID; + }; + default_1.prototype.setUUID = function (val) { + if (!val || typeof val !== 'string' || val.trim().length === 0) { + throw new Error('Missing uuid parameter. Provide a valid string uuid'); + } + this.UUID = val; + return this; + }; + default_1.prototype.getUserId = function () { + return this.UUID; + }; + default_1.prototype.setUserId = function (value) { + if (!value || typeof value !== 'string' || value.trim().length === 0) { + throw new Error('Missing or invalid userId parameter. Provide a valid string userId'); + } + this.UUID = value; + return this; + }; + default_1.prototype.getFilterExpression = function () { + return this.filterExpression; + }; + default_1.prototype.setFilterExpression = function (val) { + this.filterExpression = val; + return this; + }; + default_1.prototype.getPresenceTimeout = function () { + return this._presenceTimeout; + }; + default_1.prototype.setPresenceTimeout = function (val) { + if (val >= PRESENCE_TIMEOUT_MINIMUM) { + this._presenceTimeout = val; + } + else { + this._presenceTimeout = PRESENCE_TIMEOUT_MINIMUM; + // eslint-disable-next-line no-console + console.log('WARNING: Presence timeout is less than the minimum. Using minimum value: ', this._presenceTimeout); + } + this.setHeartbeatInterval(this._presenceTimeout / 2 - 1); + return this; + }; + default_1.prototype.setProxy = function (proxy) { + this.proxy = proxy; + }; + default_1.prototype.getHeartbeatInterval = function () { + return this._heartbeatInterval; + }; + default_1.prototype.setHeartbeatInterval = function (val) { + this._heartbeatInterval = val; + return this; + }; + // deprecated setters. + default_1.prototype.getSubscribeTimeout = function () { + return this._subscribeRequestTimeout; + }; + default_1.prototype.setSubscribeTimeout = function (val) { + this._subscribeRequestTimeout = val; + return this; + }; + default_1.prototype.getTransactionTimeout = function () { + return this._transactionalRequestTimeout; + }; + default_1.prototype.setTransactionTimeout = function (val) { + this._transactionalRequestTimeout = val; + return this; + }; + default_1.prototype.isSendBeaconEnabled = function () { + return this._useSendBeacon; + }; + default_1.prototype.setSendBeaconConfig = function (val) { + this._useSendBeacon = val; + return this; + }; + default_1.prototype.getVersion = function () { + return '7.2.3'; + }; + default_1.prototype.setReconnectionConfiguration = function (reconnectionPolicy, maximumReconnectionRetries) { + this.reconnectionConfiguration = __assign(__assign({}, config.reconnectionConfiguration), { reconnectionPolicy: reconnectionPolicy, maximumReconnectionRetries: maximumReconnectionRetries }); + }; + default_1.prototype._addPnsdkSuffix = function (name, suffix) { + this._PNSDKSuffix[name] = suffix; + }; + default_1.prototype._getPnsdkSuffix = function (separator) { + var _this = this; + return Object.keys(this._PNSDKSuffix).reduce(function (result, key) { return result + separator + _this._PNSDKSuffix[key]; }, ''); + }; + return default_1; + }()); + + var BASE64_CHARMAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + /** + * Decode a Base64 encoded string. + * + * @param paddedInput Base64 string with padding + * @returns ArrayBuffer with decoded data + */ + function decode$1(paddedInput) { + // Remove up to last two equal signs. + var input = paddedInput.replace(/==?$/, ''); + var outputLength = Math.floor((input.length / 4) * 3); + // Prepare output buffer. + var data = new ArrayBuffer(outputLength); + var view = new Uint8Array(data); + var cursor = 0; + /** + * Returns the next integer representation of a sixtet of bytes from the input + * @returns sixtet of bytes + */ + function nextSixtet() { + var char = input.charAt(cursor++); + var index = BASE64_CHARMAP.indexOf(char); + if (index === -1) { + throw new Error("Illegal character at ".concat(cursor, ": ").concat(input.charAt(cursor - 1))); + } + return index; + } + for (var i = 0; i < outputLength; i += 3) { + // Obtain four sixtets + var sx1 = nextSixtet(); + var sx2 = nextSixtet(); + var sx3 = nextSixtet(); + var sx4 = nextSixtet(); + // Encode them as three octets + var oc1 = ((sx1 & 63) << 2) | (sx2 >> 4); + var oc2 = ((sx2 & 15) << 4) | (sx3 >> 2); + var oc3 = ((sx3 & 3) << 6) | (sx4 >> 0); + view[i] = oc1; + // Skip padding bytes. + if (sx3 != 64) + view[i + 1] = oc2; + if (sx4 != 64) + view[i + 2] = oc3; + } + return data; + } + + /*eslint-disable */ + /* + CryptoJS v3.1.2 + code.google.com/p/crypto-js + (c) 2009-2013 by Jeff Mott. All rights reserved. + code.google.com/p/crypto-js/wiki/License + */ + var CryptoJS = CryptoJS || + (function (h, s) { + var f = {}, g = (f.lib = {}), q = function () { }, m = (g.Base = { + extend: function (a) { + q.prototype = this; + var c = new q(); + a && c.mixIn(a); + c.hasOwnProperty('init') || + (c.init = function () { + c.$super.init.apply(this, arguments); + }); + c.init.prototype = c; + c.$super = this; + return c; + }, + create: function () { + var a = this.extend(); + a.init.apply(a, arguments); + return a; + }, + init: function () { }, + mixIn: function (a) { + for (var c in a) + a.hasOwnProperty(c) && (this[c] = a[c]); + a.hasOwnProperty('toString') && (this.toString = a.toString); + }, + clone: function () { + return this.init.prototype.extend(this); + }, + }), r = (g.WordArray = m.extend({ + init: function (a, c) { + a = this.words = a || []; + this.sigBytes = c != s ? c : 4 * a.length; + }, + toString: function (a) { + return (a || k).stringify(this); + }, + concat: function (a) { + var c = this.words, d = a.words, b = this.sigBytes; + a = a.sigBytes; + this.clamp(); + if (b % 4) + for (var e = 0; e < a; e++) + c[(b + e) >>> 2] |= ((d[e >>> 2] >>> (24 - 8 * (e % 4))) & 255) << (24 - 8 * ((b + e) % 4)); + else if (65535 < d.length) + for (e = 0; e < a; e += 4) + c[(b + e) >>> 2] = d[e >>> 2]; + else + c.push.apply(c, d); + this.sigBytes += a; + return this; + }, + clamp: function () { + var a = this.words, c = this.sigBytes; + a[c >>> 2] &= 4294967295 << (32 - 8 * (c % 4)); + a.length = h.ceil(c / 4); + }, + clone: function () { + var a = m.clone.call(this); + a.words = this.words.slice(0); + return a; + }, + random: function (a) { + for (var c = [], d = 0; d < a; d += 4) + c.push((4294967296 * h.random()) | 0); + return new r.init(c, a); + }, + })), l = (f.enc = {}), k = (l.Hex = { + stringify: function (a) { + var c = a.words; + a = a.sigBytes; + for (var d = [], b = 0; b < a; b++) { + var e = (c[b >>> 2] >>> (24 - 8 * (b % 4))) & 255; + d.push((e >>> 4).toString(16)); + d.push((e & 15).toString(16)); + } + return d.join(''); + }, + parse: function (a) { + for (var c = a.length, d = [], b = 0; b < c; b += 2) + d[b >>> 3] |= parseInt(a.substr(b, 2), 16) << (24 - 4 * (b % 8)); + return new r.init(d, c / 2); + }, + }), n = (l.Latin1 = { + stringify: function (a) { + var c = a.words; + a = a.sigBytes; + for (var d = [], b = 0; b < a; b++) + d.push(String.fromCharCode((c[b >>> 2] >>> (24 - 8 * (b % 4))) & 255)); + return d.join(''); + }, + parse: function (a) { + for (var c = a.length, d = [], b = 0; b < c; b++) + d[b >>> 2] |= (a.charCodeAt(b) & 255) << (24 - 8 * (b % 4)); + return new r.init(d, c); + }, + }), j = (l.Utf8 = { + stringify: function (a) { + try { + return decodeURIComponent(escape(n.stringify(a))); + } + catch (c) { + throw Error('Malformed UTF-8 data'); + } + }, + parse: function (a) { + return n.parse(unescape(encodeURIComponent(a))); + }, + }), u = (g.BufferedBlockAlgorithm = m.extend({ + reset: function () { + this._data = new r.init(); + this._nDataBytes = 0; + }, + _append: function (a) { + 'string' == typeof a && (a = j.parse(a)); + this._data.concat(a); + this._nDataBytes += a.sigBytes; + }, + _process: function (a) { + var c = this._data, d = c.words, b = c.sigBytes, e = this.blockSize, f = b / (4 * e), f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0); + a = f * e; + b = h.min(4 * a, b); + if (a) { + for (var g = 0; g < a; g += e) + this._doProcessBlock(d, g); + g = d.splice(0, a); + c.sigBytes -= b; + } + return new r.init(g, b); + }, + clone: function () { + var a = m.clone.call(this); + a._data = this._data.clone(); + return a; + }, + _minBufferSize: 0, + })); + g.Hasher = u.extend({ + cfg: m.extend(), + init: function (a) { + this.cfg = this.cfg.extend(a); + this.reset(); + }, + reset: function () { + u.reset.call(this); + this._doReset(); + }, + update: function (a) { + this._append(a); + this._process(); + return this; + }, + finalize: function (a) { + a && this._append(a); + return this._doFinalize(); + }, + blockSize: 16, + _createHelper: function (a) { + return function (c, d) { + return new a.init(d).finalize(c); + }; + }, + _createHmacHelper: function (a) { + return function (c, d) { + return new t.HMAC.init(a, d).finalize(c); + }; + }, + }); + var t = (f.algo = {}); + return f; + })(Math); + // SHA256 + (function (h) { + for (var s = CryptoJS, f = s.lib, g = f.WordArray, q = f.Hasher, f = s.algo, m = [], r = [], l = function (a) { + return (4294967296 * (a - (a | 0))) | 0; + }, k = 2, n = 0; 64 > n;) { + var j; + a: { + j = k; + for (var u = h.sqrt(j), t = 2; t <= u; t++) + if (!(j % t)) { + j = !1; + break a; + } + j = !0; + } + j && (8 > n && (m[n] = l(h.pow(k, 0.5))), (r[n] = l(h.pow(k, 1 / 3))), n++); + k++; + } + var a = [], f = (f.SHA256 = q.extend({ + _doReset: function () { + this._hash = new g.init(m.slice(0)); + }, + _doProcessBlock: function (c, d) { + for (var b = this._hash.words, e = b[0], f = b[1], g = b[2], j = b[3], h = b[4], m = b[5], n = b[6], q = b[7], p = 0; 64 > p; p++) { + if (16 > p) + a[p] = c[d + p] | 0; + else { + var k = a[p - 15], l = a[p - 2]; + a[p] = + (((k << 25) | (k >>> 7)) ^ ((k << 14) | (k >>> 18)) ^ (k >>> 3)) + + a[p - 7] + + (((l << 15) | (l >>> 17)) ^ ((l << 13) | (l >>> 19)) ^ (l >>> 10)) + + a[p - 16]; + } + k = + q + + (((h << 26) | (h >>> 6)) ^ ((h << 21) | (h >>> 11)) ^ ((h << 7) | (h >>> 25))) + + ((h & m) ^ (~h & n)) + + r[p] + + a[p]; + l = + (((e << 30) | (e >>> 2)) ^ ((e << 19) | (e >>> 13)) ^ ((e << 10) | (e >>> 22))) + + ((e & f) ^ (e & g) ^ (f & g)); + q = n; + n = m; + m = h; + h = (j + k) | 0; + j = g; + g = f; + f = e; + e = (k + l) | 0; + } + b[0] = (b[0] + e) | 0; + b[1] = (b[1] + f) | 0; + b[2] = (b[2] + g) | 0; + b[3] = (b[3] + j) | 0; + b[4] = (b[4] + h) | 0; + b[5] = (b[5] + m) | 0; + b[6] = (b[6] + n) | 0; + b[7] = (b[7] + q) | 0; + }, + _doFinalize: function () { + var a = this._data, d = a.words, b = 8 * this._nDataBytes, e = 8 * a.sigBytes; + d[e >>> 5] |= 128 << (24 - (e % 32)); + d[(((e + 64) >>> 9) << 4) + 14] = h.floor(b / 4294967296); + d[(((e + 64) >>> 9) << 4) + 15] = b; + a.sigBytes = 4 * d.length; + this._process(); + return this._hash; + }, + clone: function () { + var a = q.clone.call(this); + a._hash = this._hash.clone(); + return a; + }, + })); + s.SHA256 = q._createHelper(f); + s.HmacSHA256 = q._createHmacHelper(f); + })(Math); + // HMAC SHA256 + (function () { + var h = CryptoJS, s = h.enc.Utf8; + h.algo.HMAC = h.lib.Base.extend({ + init: function (f, g) { + f = this._hasher = new f.init(); + 'string' == typeof g && (g = s.parse(g)); + var h = f.blockSize, m = 4 * h; + g.sigBytes > m && (g = f.finalize(g)); + g.clamp(); + for (var r = (this._oKey = g.clone()), l = (this._iKey = g.clone()), k = r.words, n = l.words, j = 0; j < h; j++) + (k[j] ^= 1549556828), (n[j] ^= 909522486); + r.sigBytes = l.sigBytes = m; + this.reset(); + }, + reset: function () { + var f = this._hasher; + f.reset(); + f.update(this._iKey); + }, + update: function (f) { + this._hasher.update(f); + return this; + }, + finalize: function (f) { + var g = this._hasher; + f = g.finalize(f); + g.reset(); + return g.finalize(this._oKey.clone().concat(f)); + }, + }); + })(); + // Base64 + (function () { + var u = CryptoJS, p = u.lib.WordArray; + u.enc.Base64 = { + stringify: function (d) { + var l = d.words, p = d.sigBytes, t = this._map; + d.clamp(); + d = []; + for (var r = 0; r < p; r += 3) + for (var w = (((l[r >>> 2] >>> (24 - 8 * (r % 4))) & 255) << 16) | + (((l[(r + 1) >>> 2] >>> (24 - 8 * ((r + 1) % 4))) & 255) << 8) | + ((l[(r + 2) >>> 2] >>> (24 - 8 * ((r + 2) % 4))) & 255), v = 0; 4 > v && r + 0.75 * v < p; v++) + d.push(t.charAt((w >>> (6 * (3 - v))) & 63)); + if ((l = t.charAt(64))) + for (; d.length % 4;) + d.push(l); + return d.join(''); + }, + parse: function (d) { + var l = d.length, s = this._map, t = s.charAt(64); + t && ((t = d.indexOf(t)), -1 != t && (l = t)); + for (var t = [], r = 0, w = 0; w < l; w++) + if (w % 4) { + var v = s.indexOf(d.charAt(w - 1)) << (2 * (w % 4)), b = s.indexOf(d.charAt(w)) >>> (6 - 2 * (w % 4)); + t[r >>> 2] |= (v | b) << (24 - 8 * (r % 4)); + r++; + } + return p.create(t, r); + }, + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', + }; + })(); + // BlockCipher + (function (u) { + function p(b, n, a, c, e, j, k) { + b = b + ((n & a) | (~n & c)) + e + k; + return ((b << j) | (b >>> (32 - j))) + n; + } + function d(b, n, a, c, e, j, k) { + b = b + ((n & c) | (a & ~c)) + e + k; + return ((b << j) | (b >>> (32 - j))) + n; + } + function l(b, n, a, c, e, j, k) { + b = b + (n ^ a ^ c) + e + k; + return ((b << j) | (b >>> (32 - j))) + n; + } + function s(b, n, a, c, e, j, k) { + b = b + (a ^ (n | ~c)) + e + k; + return ((b << j) | (b >>> (32 - j))) + n; + } + for (var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) + b[x] = (4294967296 * u.abs(u.sin(x + 1))) | 0; + r = r.MD5 = v.extend({ + _doReset: function () { + this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878]); + }, + _doProcessBlock: function (q, n) { + for (var a = 0; 16 > a; a++) { + var c = n + a, e = q[c]; + q[c] = (((e << 8) | (e >>> 24)) & 16711935) | (((e << 24) | (e >>> 8)) & 4278255360); + } + var a = this._hash.words, c = q[n + 0], e = q[n + 1], j = q[n + 2], k = q[n + 3], z = q[n + 4], r = q[n + 5], t = q[n + 6], w = q[n + 7], v = q[n + 8], A = q[n + 9], B = q[n + 10], C = q[n + 11], u = q[n + 12], D = q[n + 13], E = q[n + 14], x = q[n + 15], f = a[0], m = a[1], g = a[2], h = a[3], f = p(f, m, g, h, c, 7, b[0]), h = p(h, f, m, g, e, 12, b[1]), g = p(g, h, f, m, j, 17, b[2]), m = p(m, g, h, f, k, 22, b[3]), f = p(f, m, g, h, z, 7, b[4]), h = p(h, f, m, g, r, 12, b[5]), g = p(g, h, f, m, t, 17, b[6]), m = p(m, g, h, f, w, 22, b[7]), f = p(f, m, g, h, v, 7, b[8]), h = p(h, f, m, g, A, 12, b[9]), g = p(g, h, f, m, B, 17, b[10]), m = p(m, g, h, f, C, 22, b[11]), f = p(f, m, g, h, u, 7, b[12]), h = p(h, f, m, g, D, 12, b[13]), g = p(g, h, f, m, E, 17, b[14]), m = p(m, g, h, f, x, 22, b[15]), f = d(f, m, g, h, e, 5, b[16]), h = d(h, f, m, g, t, 9, b[17]), g = d(g, h, f, m, C, 14, b[18]), m = d(m, g, h, f, c, 20, b[19]), f = d(f, m, g, h, r, 5, b[20]), h = d(h, f, m, g, B, 9, b[21]), g = d(g, h, f, m, x, 14, b[22]), m = d(m, g, h, f, z, 20, b[23]), f = d(f, m, g, h, A, 5, b[24]), h = d(h, f, m, g, E, 9, b[25]), g = d(g, h, f, m, k, 14, b[26]), m = d(m, g, h, f, v, 20, b[27]), f = d(f, m, g, h, D, 5, b[28]), h = d(h, f, m, g, j, 9, b[29]), g = d(g, h, f, m, w, 14, b[30]), m = d(m, g, h, f, u, 20, b[31]), f = l(f, m, g, h, r, 4, b[32]), h = l(h, f, m, g, v, 11, b[33]), g = l(g, h, f, m, C, 16, b[34]), m = l(m, g, h, f, E, 23, b[35]), f = l(f, m, g, h, e, 4, b[36]), h = l(h, f, m, g, z, 11, b[37]), g = l(g, h, f, m, w, 16, b[38]), m = l(m, g, h, f, B, 23, b[39]), f = l(f, m, g, h, D, 4, b[40]), h = l(h, f, m, g, c, 11, b[41]), g = l(g, h, f, m, k, 16, b[42]), m = l(m, g, h, f, t, 23, b[43]), f = l(f, m, g, h, A, 4, b[44]), h = l(h, f, m, g, u, 11, b[45]), g = l(g, h, f, m, x, 16, b[46]), m = l(m, g, h, f, j, 23, b[47]), f = s(f, m, g, h, c, 6, b[48]), h = s(h, f, m, g, w, 10, b[49]), g = s(g, h, f, m, E, 15, b[50]), m = s(m, g, h, f, r, 21, b[51]), f = s(f, m, g, h, u, 6, b[52]), h = s(h, f, m, g, k, 10, b[53]), g = s(g, h, f, m, B, 15, b[54]), m = s(m, g, h, f, e, 21, b[55]), f = s(f, m, g, h, v, 6, b[56]), h = s(h, f, m, g, x, 10, b[57]), g = s(g, h, f, m, t, 15, b[58]), m = s(m, g, h, f, D, 21, b[59]), f = s(f, m, g, h, z, 6, b[60]), h = s(h, f, m, g, C, 10, b[61]), g = s(g, h, f, m, j, 15, b[62]), m = s(m, g, h, f, A, 21, b[63]); + a[0] = (a[0] + f) | 0; + a[1] = (a[1] + m) | 0; + a[2] = (a[2] + g) | 0; + a[3] = (a[3] + h) | 0; + }, + _doFinalize: function () { + var b = this._data, n = b.words, a = 8 * this._nDataBytes, c = 8 * b.sigBytes; + n[c >>> 5] |= 128 << (24 - (c % 32)); + var e = u.floor(a / 4294967296); + n[(((c + 64) >>> 9) << 4) + 15] = (((e << 8) | (e >>> 24)) & 16711935) | (((e << 24) | (e >>> 8)) & 4278255360); + n[(((c + 64) >>> 9) << 4) + 14] = (((a << 8) | (a >>> 24)) & 16711935) | (((a << 24) | (a >>> 8)) & 4278255360); + b.sigBytes = 4 * (n.length + 1); + this._process(); + b = this._hash; + n = b.words; + for (a = 0; 4 > a; a++) + (c = n[a]), (n[a] = (((c << 8) | (c >>> 24)) & 16711935) | (((c << 24) | (c >>> 8)) & 4278255360)); + return b; + }, + clone: function () { + var b = v.clone.call(this); + b._hash = this._hash.clone(); + return b; + }, + }); + t.MD5 = v._createHelper(r); + t.HmacMD5 = v._createHmacHelper(r); + })(Math); + (function () { + var u = CryptoJS, p = u.lib, d = p.Base, l = p.WordArray, p = u.algo, s = (p.EvpKDF = d.extend({ + cfg: d.extend({ keySize: 4, hasher: p.MD5, iterations: 1 }), + init: function (d) { + this.cfg = this.cfg.extend(d); + }, + compute: function (d, r) { + for (var p = this.cfg, s = p.hasher.create(), b = l.create(), u = b.words, q = p.keySize, p = p.iterations; u.length < q;) { + n && s.update(n); + var n = s.update(d).finalize(r); + s.reset(); + for (var a = 1; a < p; a++) + (n = s.finalize(n)), s.reset(); + b.concat(n); + } + b.sigBytes = 4 * q; + return b; + }, + })); + u.EvpKDF = function (d, l, p) { + return s.create(p).compute(d, l); + }; + })(); + // Cipher + CryptoJS.lib.Cipher || + (function (u) { + var p = CryptoJS, d = p.lib, l = d.Base, s = d.WordArray, t = d.BufferedBlockAlgorithm, r = p.enc.Base64, w = p.algo.EvpKDF, v = (d.Cipher = t.extend({ + cfg: l.extend(), + createEncryptor: function (e, a) { + return this.create(this._ENC_XFORM_MODE, e, a); + }, + createDecryptor: function (e, a) { + return this.create(this._DEC_XFORM_MODE, e, a); + }, + init: function (e, a, b) { + this.cfg = this.cfg.extend(b); + this._xformMode = e; + this._key = a; + this.reset(); + }, + reset: function () { + t.reset.call(this); + this._doReset(); + }, + process: function (e) { + this._append(e); + return this._process(); + }, + finalize: function (e) { + e && this._append(e); + return this._doFinalize(); + }, + keySize: 4, + ivSize: 4, + _ENC_XFORM_MODE: 1, + _DEC_XFORM_MODE: 2, + _createHelper: function (e) { + return { + encrypt: function (b, k, d) { + return ('string' == typeof k ? c : a).encrypt(e, b, k, d); + }, + decrypt: function (b, k, d) { + return ('string' == typeof k ? c : a).decrypt(e, b, k, d); + }, + }; + }, + })); + d.StreamCipher = v.extend({ + _doFinalize: function () { + return this._process(!0); + }, + blockSize: 1, + }); + var b = (p.mode = {}), x = function (e, a, b) { + var c = this._iv; + c ? (this._iv = u) : (c = this._prevBlock); + for (var d = 0; d < b; d++) + e[a + d] ^= c[d]; + }, q = (d.BlockCipherMode = l.extend({ + createEncryptor: function (e, a) { + return this.Encryptor.create(e, a); + }, + createDecryptor: function (e, a) { + return this.Decryptor.create(e, a); + }, + init: function (e, a) { + this._cipher = e; + this._iv = a; + }, + })).extend(); + q.Encryptor = q.extend({ + processBlock: function (e, a) { + var b = this._cipher, c = b.blockSize; + x.call(this, e, a, c); + b.encryptBlock(e, a); + this._prevBlock = e.slice(a, a + c); + }, + }); + q.Decryptor = q.extend({ + processBlock: function (e, a) { + var b = this._cipher, c = b.blockSize, d = e.slice(a, a + c); + b.decryptBlock(e, a); + x.call(this, e, a, c); + this._prevBlock = d; + }, + }); + b = b.CBC = q; + q = (p.pad = {}).Pkcs7 = { + pad: function (a, b) { + for (var c = 4 * b, c = c - (a.sigBytes % c), d = (c << 24) | (c << 16) | (c << 8) | c, l = [], n = 0; n < c; n += 4) + l.push(d); + c = s.create(l, c); + a.concat(c); + }, + unpad: function (a) { + a.sigBytes -= a.words[(a.sigBytes - 1) >>> 2] & 255; + }, + }; + d.BlockCipher = v.extend({ + cfg: v.cfg.extend({ mode: b, padding: q }), + reset: function () { + v.reset.call(this); + var a = this.cfg, b = a.iv, a = a.mode; + if (this._xformMode == this._ENC_XFORM_MODE) + var c = a.createEncryptor; + else + (c = a.createDecryptor), (this._minBufferSize = 1); + this._mode = c.call(a, this, b && b.words); + }, + _doProcessBlock: function (a, b) { + this._mode.processBlock(a, b); + }, + _doFinalize: function () { + var a = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + a.pad(this._data, this.blockSize); + var b = this._process(!0); + } + else + (b = this._process(!0)), a.unpad(b); + return b; + }, + blockSize: 4, + }); + var n = (d.CipherParams = l.extend({ + init: function (a) { + this.mixIn(a); + }, + toString: function (a) { + return (a || this.formatter).stringify(this); + }, + })), b = ((p.format = {}).OpenSSL = { + stringify: function (a) { + var b = a.ciphertext; + a = a.salt; + return (a ? s.create([1398893684, 1701076831]).concat(a).concat(b) : b).toString(r); + }, + parse: function (a) { + a = r.parse(a); + var b = a.words; + if (1398893684 == b[0] && 1701076831 == b[1]) { + var c = s.create(b.slice(2, 4)); + b.splice(0, 4); + a.sigBytes -= 16; + } + return n.create({ ciphertext: a, salt: c }); + }, + }), a = (d.SerializableCipher = l.extend({ + cfg: l.extend({ format: b }), + encrypt: function (a, b, c, d) { + d = this.cfg.extend(d); + var l = a.createEncryptor(c, d); + b = l.finalize(b); + l = l.cfg; + return n.create({ + ciphertext: b, + key: c, + iv: l.iv, + algorithm: a, + mode: l.mode, + padding: l.padding, + blockSize: a.blockSize, + formatter: d.format, + }); + }, + decrypt: function (a, b, c, d) { + d = this.cfg.extend(d); + b = this._parse(b, d.format); + return a.createDecryptor(c, d).finalize(b.ciphertext); + }, + _parse: function (a, b) { + return 'string' == typeof a ? b.parse(a, this) : a; + }, + })), p = ((p.kdf = {}).OpenSSL = { + execute: function (a, b, c, d) { + d || (d = s.random(8)); + a = w.create({ keySize: b + c }).compute(a, d); + c = s.create(a.words.slice(b), 4 * c); + a.sigBytes = 4 * b; + return n.create({ key: a, iv: c, salt: d }); + }, + }), c = (d.PasswordBasedCipher = a.extend({ + cfg: a.cfg.extend({ kdf: p }), + encrypt: function (b, c, d, l) { + l = this.cfg.extend(l); + d = l.kdf.execute(d, b.keySize, b.ivSize); + l.iv = d.iv; + b = a.encrypt.call(this, b, c, d.key, l); + b.mixIn(d); + return b; + }, + decrypt: function (b, c, d, l) { + l = this.cfg.extend(l); + c = this._parse(c, l.format); + d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt); + l.iv = d.iv; + return a.decrypt.call(this, b, c, d.key, l); + }, + })); + })(); + // AES + (function () { + for (var u = CryptoJS, p = u.lib.BlockCipher, d = u.algo, l = [], s = [], t = [], r = [], w = [], v = [], b = [], x = [], q = [], n = [], a = [], c = 0; 256 > c; c++) + a[c] = 128 > c ? c << 1 : (c << 1) ^ 283; + for (var e = 0, j = 0, c = 0; 256 > c; c++) { + var k = j ^ (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4), k = (k >>> 8) ^ (k & 255) ^ 99; + l[e] = k; + s[k] = e; + var z = a[e], F = a[z], G = a[F], y = (257 * a[k]) ^ (16843008 * k); + t[e] = (y << 24) | (y >>> 8); + r[e] = (y << 16) | (y >>> 16); + w[e] = (y << 8) | (y >>> 24); + v[e] = y; + y = (16843009 * G) ^ (65537 * F) ^ (257 * z) ^ (16843008 * e); + b[k] = (y << 24) | (y >>> 8); + x[k] = (y << 16) | (y >>> 16); + q[k] = (y << 8) | (y >>> 24); + n[k] = y; + e ? ((e = z ^ a[a[a[G ^ z]]]), (j ^= a[a[j]])) : (e = j = 1); + } + var H = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], d = (d.AES = p.extend({ + _doReset: function () { + for (var a = this._key, c = a.words, d = a.sigBytes / 4, a = 4 * ((this._nRounds = d + 6) + 1), e = (this._keySchedule = []), j = 0; j < a; j++) + if (j < d) + e[j] = c[j]; + else { + var k = e[j - 1]; + j % d + ? 6 < d && + 4 == j % d && + (k = (l[k >>> 24] << 24) | (l[(k >>> 16) & 255] << 16) | (l[(k >>> 8) & 255] << 8) | l[k & 255]) + : ((k = (k << 8) | (k >>> 24)), + (k = (l[k >>> 24] << 24) | (l[(k >>> 16) & 255] << 16) | (l[(k >>> 8) & 255] << 8) | l[k & 255]), + (k ^= H[(j / d) | 0] << 24)); + e[j] = e[j - d] ^ k; + } + c = this._invKeySchedule = []; + for (d = 0; d < a; d++) + (j = a - d), + (k = d % 4 ? e[j] : e[j - 4]), + (c[d] = + 4 > d || 4 >= j ? k : b[l[k >>> 24]] ^ x[l[(k >>> 16) & 255]] ^ q[l[(k >>> 8) & 255]] ^ n[l[k & 255]]); + }, + encryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l); + }, + decryptBlock: function (a, c) { + var d = a[c + 1]; + a[c + 1] = a[c + 3]; + a[c + 3] = d; + this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s); + d = a[c + 1]; + a[c + 1] = a[c + 3]; + a[c + 3] = d; + }, + _doCryptBlock: function (a, b, c, d, e, j, l, f) { + for (var m = this._nRounds, g = a[b] ^ c[0], h = a[b + 1] ^ c[1], k = a[b + 2] ^ c[2], n = a[b + 3] ^ c[3], p = 4, r = 1; r < m; r++) + var q = d[g >>> 24] ^ e[(h >>> 16) & 255] ^ j[(k >>> 8) & 255] ^ l[n & 255] ^ c[p++], s = d[h >>> 24] ^ e[(k >>> 16) & 255] ^ j[(n >>> 8) & 255] ^ l[g & 255] ^ c[p++], t = d[k >>> 24] ^ e[(n >>> 16) & 255] ^ j[(g >>> 8) & 255] ^ l[h & 255] ^ c[p++], n = d[n >>> 24] ^ e[(g >>> 16) & 255] ^ j[(h >>> 8) & 255] ^ l[k & 255] ^ c[p++], g = q, h = s, k = t; + q = ((f[g >>> 24] << 24) | (f[(h >>> 16) & 255] << 16) | (f[(k >>> 8) & 255] << 8) | f[n & 255]) ^ c[p++]; + s = ((f[h >>> 24] << 24) | (f[(k >>> 16) & 255] << 16) | (f[(n >>> 8) & 255] << 8) | f[g & 255]) ^ c[p++]; + t = ((f[k >>> 24] << 24) | (f[(n >>> 16) & 255] << 16) | (f[(g >>> 8) & 255] << 8) | f[h & 255]) ^ c[p++]; + n = ((f[n >>> 24] << 24) | (f[(g >>> 16) & 255] << 16) | (f[(h >>> 8) & 255] << 8) | f[k & 255]) ^ c[p++]; + a[b] = q; + a[b + 1] = s; + a[b + 2] = t; + a[b + 3] = n; + }, + keySize: 8, + })); + u.AES = p._createHelper(d); + })(); + // Mode ECB + CryptoJS.mode.ECB = (function () { + var ECB = CryptoJS.lib.BlockCipherMode.extend(); + ECB.Encryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.encryptBlock(words, offset); + }, + }); + ECB.Decryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.decryptBlock(words, offset); + }, + }); + return ECB; + })(); + var hmacSha256 = CryptoJS; + + function bufferToWordArray(b) { + var wa = []; + var i; + for (i = 0; i < b.length; i += 1) { + wa[(i / 4) | 0] |= b[i] << (24 - 8 * i); + } + return hmacSha256.lib.WordArray.create(wa, b.length); + } + var default_1$a = /** @class */ (function () { + function default_1(_a) { + var config = _a.config; + this._config = config; + this._iv = '0123456789012345'; + this._allowedKeyEncodings = ['hex', 'utf8', 'base64', 'binary']; + this._allowedKeyLengths = [128, 256]; + this._allowedModes = ['ecb', 'cbc']; + this._defaultOptions = { + encryptKey: true, + keyEncoding: 'utf8', + keyLength: 256, + mode: 'cbc', + }; + } + default_1.prototype.HMACSHA256 = function (data) { + var hash = hmacSha256.HmacSHA256(data, this._config.secretKey); + return hash.toString(hmacSha256.enc.Base64); + }; + default_1.prototype.SHA256 = function (s) { + return hmacSha256.SHA256(s).toString(hmacSha256.enc.Hex); + }; + default_1.prototype._parseOptions = function (incomingOptions) { + // Defaults + var options = incomingOptions || {}; + if (!options.hasOwnProperty('encryptKey')) + options.encryptKey = this._defaultOptions.encryptKey; + if (!options.hasOwnProperty('keyEncoding')) + options.keyEncoding = this._defaultOptions.keyEncoding; + if (!options.hasOwnProperty('keyLength')) + options.keyLength = this._defaultOptions.keyLength; + if (!options.hasOwnProperty('mode')) + options.mode = this._defaultOptions.mode; + // Validation + if (this._allowedKeyEncodings.indexOf(options.keyEncoding.toLowerCase()) === -1) { + options.keyEncoding = this._defaultOptions.keyEncoding; + } + if (this._allowedKeyLengths.indexOf(parseInt(options.keyLength, 10)) === -1) { + options.keyLength = this._defaultOptions.keyLength; + } + if (this._allowedModes.indexOf(options.mode.toLowerCase()) === -1) { + options.mode = this._defaultOptions.mode; + } + return options; + }; + default_1.prototype._decodeKey = function (key, options) { + if (options.keyEncoding === 'base64') { + return hmacSha256.enc.Base64.parse(key); + } + if (options.keyEncoding === 'hex') { + return hmacSha256.enc.Hex.parse(key); + } + return key; + }; + default_1.prototype._getPaddedKey = function (key, options) { + key = this._decodeKey(key, options); + if (options.encryptKey) { + return hmacSha256.enc.Utf8.parse(this.SHA256(key).slice(0, 32)); + } + return key; + }; + default_1.prototype._getMode = function (options) { + if (options.mode === 'ecb') { + return hmacSha256.mode.ECB; + } + return hmacSha256.mode.CBC; + }; + default_1.prototype._getIV = function (options) { + return options.mode === 'cbc' ? hmacSha256.enc.Utf8.parse(this._iv) : null; + }; + default_1.prototype._getRandomIV = function () { + return hmacSha256.lib.WordArray.random(16); + }; + default_1.prototype.encrypt = function (data, customCipherKey, options) { + if (this._config.customEncrypt) { + return this._config.customEncrypt(data); + } + return this.pnEncrypt(data, customCipherKey, options); + }; + default_1.prototype.decrypt = function (data, customCipherKey, options) { + if (this._config.customDecrypt) { + return this._config.customDecrypt(data); + } + return this.pnDecrypt(data, customCipherKey, options); + }; + default_1.prototype.pnEncrypt = function (data, customCipherKey, options) { + if (!customCipherKey && !this._config.cipherKey) + return data; + options = this._parseOptions(options); + var mode = this._getMode(options); + var cipherKey = this._getPaddedKey(customCipherKey || this._config.cipherKey, options); + if (this._config.useRandomIVs) { + var waIv = this._getRandomIV(); + var waPayload = hmacSha256.AES.encrypt(data, cipherKey, { iv: waIv, mode: mode }).ciphertext; + return waIv.clone().concat(waPayload.clone()).toString(hmacSha256.enc.Base64); + } + var iv = this._getIV(options); + var encryptedHexArray = hmacSha256.AES.encrypt(data, cipherKey, { iv: iv, mode: mode }).ciphertext; + var base64Encrypted = encryptedHexArray.toString(hmacSha256.enc.Base64); + return base64Encrypted || data; + }; + default_1.prototype.pnDecrypt = function (data, customCipherKey, options) { + if (!customCipherKey && !this._config.cipherKey) + return data; + options = this._parseOptions(options); + var mode = this._getMode(options); + var cipherKey = this._getPaddedKey(customCipherKey || this._config.cipherKey, options); + if (this._config.useRandomIVs) { + var ciphertext = new Uint8ClampedArray(decode$1(data)); + var iv = bufferToWordArray(ciphertext.slice(0, 16)); + var payload = bufferToWordArray(ciphertext.slice(16)); + try { + var plainJSON = hmacSha256.AES.decrypt({ ciphertext: payload }, cipherKey, { iv: iv, mode: mode }).toString(hmacSha256.enc.Utf8); + var plaintext = JSON.parse(plainJSON); + return plaintext; + } + catch (e) { + return null; + } + } + else { + var iv = this._getIV(options); + try { + var ciphertext = hmacSha256.enc.Base64.parse(data); + var plainJSON = hmacSha256.AES.decrypt({ ciphertext: ciphertext }, cipherKey, { iv: iv, mode: mode }).toString(hmacSha256.enc.Utf8); + var plaintext = JSON.parse(plainJSON); + return plaintext; + } + catch (e) { + return null; + } + } + }; + return default_1; + }()); + + var default_1$9 = /** @class */ (function () { + function default_1(_a) { + var timeEndpoint = _a.timeEndpoint; + this._timeEndpoint = timeEndpoint; + } + default_1.prototype.onReconnection = function (reconnectionCallback) { + this._reconnectionCallback = reconnectionCallback; + }; + default_1.prototype.startPolling = function () { + this._timeTimer = setInterval(this._performTimeLoop.bind(this), 3000); + }; + default_1.prototype.stopPolling = function () { + clearInterval(this._timeTimer); + }; + default_1.prototype._performTimeLoop = function () { + var _this = this; + this._timeEndpoint(function (status) { + if (!status.error) { + clearInterval(_this._timeTimer); + _this._reconnectionCallback(); + } + }); + }; + return default_1; + }()); + + /* */ + var hashCode = function (payload) { + var hash = 0; + if (payload.length === 0) + return hash; + for (var i = 0; i < payload.length; i += 1) { + var character = payload.charCodeAt(i); + hash = (hash << 5) - hash + character; // eslint-disable-line + hash = hash & hash; // eslint-disable-line + } + return hash; + }; + var default_1$8 = /** @class */ (function () { + function default_1(_a) { + var config = _a.config; + this.hashHistory = []; + this._config = config; + } + default_1.prototype.getKey = function (message) { + var hashedPayload = hashCode(JSON.stringify(message.payload)).toString(); + var timetoken = message.publishMetaData.publishTimetoken; + return "".concat(timetoken, "-").concat(hashedPayload); + }; + default_1.prototype.isDuplicate = function (message) { + return this.hashHistory.includes(this.getKey(message)); + }; + default_1.prototype.addEntry = function (message) { + if (this.hashHistory.length >= this._config.maximumCacheSize) { + this.hashHistory.shift(); + } + this.hashHistory.push(this.getKey(message)); + }; + default_1.prototype.clearHistory = function () { + this.hashHistory = []; + }; + return default_1; + }()); + + function objectToList(o) { + var l = []; + Object.keys(o).forEach(function (key) { return l.push(key); }); + return l; + } + function encodeString(input) { + return encodeURIComponent(input).replace(/[!~*'()]/g, function (x) { return "%".concat(x.charCodeAt(0).toString(16).toUpperCase()); }); + } + function objectToListSorted(o) { + return objectToList(o).sort(); + } + function signPamFromParams(params) { + var l = objectToListSorted(params); + return l.map(function (paramKey) { return "".concat(paramKey, "=").concat(encodeString(params[paramKey])); }).join('&'); + } + function endsWith(searchString, suffix) { + return searchString.indexOf(suffix, this.length - suffix.length) !== -1; + } + function createPromise() { + var successResolve; + var failureResolve; + var promise = new Promise(function (fulfill, reject) { + successResolve = fulfill; + failureResolve = reject; + }); + return { promise: promise, reject: failureResolve, fulfill: successResolve }; + } + var utils$5 = { + signPamFromParams: signPamFromParams, + endsWith: endsWith, + createPromise: createPromise, + encodeString: encodeString, + }; + + /* */ + var categories = { + // SDK will announce when the network appears to be connected again. + PNNetworkUpCategory: 'PNNetworkUpCategory', + // SDK will announce when the network appears to down. + PNNetworkDownCategory: 'PNNetworkDownCategory', + // call failed when network was unable to complete the call. + PNNetworkIssuesCategory: 'PNNetworkIssuesCategory', + // network call timed out + PNTimeoutCategory: 'PNTimeoutCategory', + // server responded with bad response + PNBadRequestCategory: 'PNBadRequestCategory', + // server responded with access denied + PNAccessDeniedCategory: 'PNAccessDeniedCategory', + // something strange happened; please check the logs. + PNUnknownCategory: 'PNUnknownCategory', + // on reconnection + PNReconnectedCategory: 'PNReconnectedCategory', + PNConnectedCategory: 'PNConnectedCategory', + PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', + PNDisconnectedCategory: 'PNDisconnectedCategory', + }; + + var default_1$7 = /** @class */ (function () { + function default_1(_a) { + var subscribeEndpoint = _a.subscribeEndpoint, leaveEndpoint = _a.leaveEndpoint, heartbeatEndpoint = _a.heartbeatEndpoint, setStateEndpoint = _a.setStateEndpoint, timeEndpoint = _a.timeEndpoint, getFileUrl = _a.getFileUrl, config = _a.config, crypto = _a.crypto, listenerManager = _a.listenerManager; + this._listenerManager = listenerManager; + this._config = config; + this._leaveEndpoint = leaveEndpoint; + this._heartbeatEndpoint = heartbeatEndpoint; + this._setStateEndpoint = setStateEndpoint; + this._subscribeEndpoint = subscribeEndpoint; + this._getFileUrl = getFileUrl; + this._crypto = crypto; + this._channels = {}; + this._presenceChannels = {}; + this._heartbeatChannels = {}; + this._heartbeatChannelGroups = {}; + this._channelGroups = {}; + this._presenceChannelGroups = {}; + this._pendingChannelSubscriptions = []; + this._pendingChannelGroupSubscriptions = []; + this._currentTimetoken = 0; + this._lastTimetoken = 0; + this._storedTimetoken = null; + this._subscriptionStatusAnnounced = false; + this._isOnline = true; + this._reconnectionManager = new default_1$9({ timeEndpoint: timeEndpoint }); + this._dedupingManager = new default_1$8({ config: config }); + } + default_1.prototype.adaptStateChange = function (args, callback) { + var _this = this; + var state = args.state, _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = args.withHeartbeat, withHeartbeat = _c === void 0 ? false : _c; + channels.forEach(function (channel) { + if (channel in _this._channels) + _this._channels[channel].state = state; + }); + channelGroups.forEach(function (channelGroup) { + if (channelGroup in _this._channelGroups) { + _this._channelGroups[channelGroup].state = state; + } + }); + if (withHeartbeat) { + var presenceState_1 = {}; + channels.forEach(function (channel) { return (presenceState_1[channel] = state); }); + channelGroups.forEach(function (group) { return (presenceState_1[group] = state); }); + return this._heartbeatEndpoint({ channels: channels, channelGroups: channelGroups, state: presenceState_1 }, callback); + } + return this._setStateEndpoint({ state: state, channels: channels, channelGroups: channelGroups }, callback); + }; + default_1.prototype.adaptPresenceChange = function (args) { + var _this = this; + var connected = args.connected, _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b; + if (connected) { + channels.forEach(function (channel) { + _this._heartbeatChannels[channel] = { state: {} }; + }); + channelGroups.forEach(function (channelGroup) { + _this._heartbeatChannelGroups[channelGroup] = { state: {} }; + }); + } + else { + channels.forEach(function (channel) { + if (channel in _this._heartbeatChannels) { + delete _this._heartbeatChannels[channel]; + } + }); + channelGroups.forEach(function (channelGroup) { + if (channelGroup in _this._heartbeatChannelGroups) { + delete _this._heartbeatChannelGroups[channelGroup]; + } + }); + if (this._config.suppressLeaveEvents === false) { + this._leaveEndpoint({ channels: channels, channelGroups: channelGroups }, function (status) { + _this._listenerManager.announceStatus(status); + }); + } + } + this.reconnect(); + }; + default_1.prototype.adaptSubscribeChange = function (args) { + var _this = this; + var timetoken = args.timetoken, _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = args.withPresence, withPresence = _c === void 0 ? false : _c, _d = args.withHeartbeats, withHeartbeats = _d === void 0 ? false : _d; + if (!this._config.subscribeKey || this._config.subscribeKey === '') { + // eslint-disable-next-line + if (console && console.log) { + console.log('subscribe key missing; aborting subscribe'); //eslint-disable-line + } + return; + } + if (timetoken) { + this._lastTimetoken = this._currentTimetoken; + this._currentTimetoken = timetoken; + } + // reset the current timetoken to get a connect event. + // $FlowFixMe + if (this._currentTimetoken !== '0' && this._currentTimetoken !== 0) { + this._storedTimetoken = this._currentTimetoken; + this._currentTimetoken = 0; + } + channels.forEach(function (channel) { + _this._channels[channel] = { state: {} }; + if (withPresence) + _this._presenceChannels[channel] = {}; + if (withHeartbeats || _this._config.getHeartbeatInterval()) + _this._heartbeatChannels[channel] = {}; + _this._pendingChannelSubscriptions.push(channel); + }); + channelGroups.forEach(function (channelGroup) { + _this._channelGroups[channelGroup] = { state: {} }; + if (withPresence) + _this._presenceChannelGroups[channelGroup] = {}; + if (withHeartbeats || _this._config.getHeartbeatInterval()) + _this._heartbeatChannelGroups[channelGroup] = {}; + _this._pendingChannelGroupSubscriptions.push(channelGroup); + }); + this._subscriptionStatusAnnounced = false; + this.reconnect(); + }; + default_1.prototype.adaptUnsubscribeChange = function (args, isOffline) { + var _this = this; + var _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b; + // keep track of which channels and channel groups + // we are going to unsubscribe from. + var actualChannels = []; + var actualChannelGroups = []; + // + channels.forEach(function (channel) { + if (channel in _this._channels) { + delete _this._channels[channel]; + actualChannels.push(channel); + if (channel in _this._heartbeatChannels) { + delete _this._heartbeatChannels[channel]; + } + } + if (channel in _this._presenceChannels) { + delete _this._presenceChannels[channel]; + actualChannels.push(channel); + } + }); + channelGroups.forEach(function (channelGroup) { + if (channelGroup in _this._channelGroups) { + delete _this._channelGroups[channelGroup]; + actualChannelGroups.push(channelGroup); + if (channelGroup in _this._heartbeatChannelGroups) { + delete _this._heartbeatChannelGroups[channelGroup]; + } + } + if (channelGroup in _this._presenceChannelGroups) { + delete _this._presenceChannelGroups[channelGroup]; + actualChannelGroups.push(channelGroup); + } + }); + // no-op if there are no channels and cg's to unsubscribe from. + if (actualChannels.length === 0 && actualChannelGroups.length === 0) { + return; + } + if (this._config.suppressLeaveEvents === false && !isOffline) { + this._leaveEndpoint({ channels: actualChannels, channelGroups: actualChannelGroups }, function (status) { + status.affectedChannels = actualChannels; + status.affectedChannelGroups = actualChannelGroups; + status.currentTimetoken = _this._currentTimetoken; + status.lastTimetoken = _this._lastTimetoken; + _this._listenerManager.announceStatus(status); + }); + } + // if we have nothing to subscribe to, reset the timetoken. + if (Object.keys(this._channels).length === 0 && + Object.keys(this._presenceChannels).length === 0 && + Object.keys(this._channelGroups).length === 0 && + Object.keys(this._presenceChannelGroups).length === 0) { + this._lastTimetoken = 0; + this._currentTimetoken = 0; + this._storedTimetoken = null; + this._region = null; + this._reconnectionManager.stopPolling(); + } + this.reconnect(); + }; + default_1.prototype.unsubscribeAll = function (isOffline) { + this.adaptUnsubscribeChange({ + channels: this.getSubscribedChannels(), + channelGroups: this.getSubscribedChannelGroups(), + }, isOffline); + }; + default_1.prototype.getHeartbeatChannels = function () { + return Object.keys(this._heartbeatChannels); + }; + default_1.prototype.getHeartbeatChannelGroups = function () { + return Object.keys(this._heartbeatChannelGroups); + }; + default_1.prototype.getSubscribedChannels = function () { + return Object.keys(this._channels); + }; + default_1.prototype.getSubscribedChannelGroups = function () { + return Object.keys(this._channelGroups); + }; + default_1.prototype.reconnect = function () { + this._startSubscribeLoop(); + this._registerHeartbeatTimer(); + }; + default_1.prototype.disconnect = function () { + this._stopSubscribeLoop(); + this._stopHeartbeatTimer(); + this._reconnectionManager.stopPolling(); + }; + default_1.prototype._registerHeartbeatTimer = function () { + this._stopHeartbeatTimer(); + // if the interval is 0 or undefined, do not queue up heartbeating + if (this._config.getHeartbeatInterval() === 0 || this._config.getHeartbeatInterval() === undefined) { + return; + } + this._performHeartbeatLoop(); + // $FlowFixMe + this._heartbeatTimer = setInterval(this._performHeartbeatLoop.bind(this), this._config.getHeartbeatInterval() * 1000); + }; + default_1.prototype._stopHeartbeatTimer = function () { + if (this._heartbeatTimer) { + // $FlowFixMe + clearInterval(this._heartbeatTimer); + this._heartbeatTimer = null; + } + }; + default_1.prototype._performHeartbeatLoop = function () { + var _this = this; + var heartbeatChannels = this.getHeartbeatChannels(); + var heartbeatChannelGroups = this.getHeartbeatChannelGroups(); + var presenceState = {}; + if (heartbeatChannels.length === 0 && heartbeatChannelGroups.length === 0) { + return; + } + this.getSubscribedChannels().forEach(function (channel) { + var channelState = _this._channels[channel].state; + if (Object.keys(channelState).length) { + presenceState[channel] = channelState; + } + }); + this.getSubscribedChannelGroups().forEach(function (channelGroup) { + var channelGroupState = _this._channelGroups[channelGroup].state; + if (Object.keys(channelGroupState).length) { + presenceState[channelGroup] = channelGroupState; + } + }); + var onHeartbeat = function (status) { + if (status.error && _this._config.announceFailedHeartbeats) { + _this._listenerManager.announceStatus(status); + } + if (status.error && _this._config.autoNetworkDetection && _this._isOnline) { + _this._isOnline = false; + _this.disconnect(); + _this._listenerManager.announceNetworkDown(); + _this.reconnect(); + } + if (!status.error && _this._config.announceSuccessfulHeartbeats) { + _this._listenerManager.announceStatus(status); + } + }; + this._heartbeatEndpoint({ + channels: heartbeatChannels, + channelGroups: heartbeatChannelGroups, + state: presenceState, + }, onHeartbeat.bind(this)); + }; + default_1.prototype._startSubscribeLoop = function () { + var _this = this; + this._stopSubscribeLoop(); + var presenceState = {}; + var channels = []; + var channelGroups = []; + Object.keys(this._channels).forEach(function (channel) { + var channelState = _this._channels[channel].state; + if (Object.keys(channelState).length) { + presenceState[channel] = channelState; + } + channels.push(channel); + }); + Object.keys(this._presenceChannels).forEach(function (channel) { + channels.push("".concat(channel, "-pnpres")); + }); + Object.keys(this._channelGroups).forEach(function (channelGroup) { + var channelGroupState = _this._channelGroups[channelGroup].state; + if (Object.keys(channelGroupState).length) { + presenceState[channelGroup] = channelGroupState; + } + channelGroups.push(channelGroup); + }); + Object.keys(this._presenceChannelGroups).forEach(function (channelGroup) { + channelGroups.push("".concat(channelGroup, "-pnpres")); + }); + if (channels.length === 0 && channelGroups.length === 0) { + return; + } + var subscribeArgs = { + channels: channels, + channelGroups: channelGroups, + state: presenceState, + timetoken: this._currentTimetoken, + filterExpression: this._config.filterExpression, + region: this._region, + }; + this._subscribeCall = this._subscribeEndpoint(subscribeArgs, this._processSubscribeResponse.bind(this)); + }; + default_1.prototype._processSubscribeResponse = function (status, payload) { + var _this = this; + if (status.error) { + // if error comes from request abort, ignore + if (status.errorData && status.errorData.message === 'Aborted') { + return; + } + // if we timeout from server, restart the loop. + if (status.category === categories.PNTimeoutCategory) { + this._startSubscribeLoop(); + } + else if (status.category === categories.PNNetworkIssuesCategory) { + // we lost internet connection, alert the reconnection manager and terminate all loops + this.disconnect(); + if (status.error && this._config.autoNetworkDetection && this._isOnline) { + this._isOnline = false; + this._listenerManager.announceNetworkDown(); + } + this._reconnectionManager.onReconnection(function () { + if (_this._config.autoNetworkDetection && !_this._isOnline) { + _this._isOnline = true; + _this._listenerManager.announceNetworkUp(); + } + _this.reconnect(); + _this._subscriptionStatusAnnounced = true; + var reconnectedAnnounce = { + category: categories.PNReconnectedCategory, + operation: status.operation, + lastTimetoken: _this._lastTimetoken, + currentTimetoken: _this._currentTimetoken, + }; + _this._listenerManager.announceStatus(reconnectedAnnounce); + }); + this._reconnectionManager.startPolling(); + this._listenerManager.announceStatus(status); + } + else if (status.category === categories.PNBadRequestCategory) { + this._stopHeartbeatTimer(); + this._listenerManager.announceStatus(status); + } + else { + this._listenerManager.announceStatus(status); + } + return; + } + if (this._storedTimetoken) { + this._currentTimetoken = this._storedTimetoken; + this._storedTimetoken = null; + } + else { + this._lastTimetoken = this._currentTimetoken; + this._currentTimetoken = payload.metadata.timetoken; + } + if (!this._subscriptionStatusAnnounced) { + var connectedAnnounce = {}; + connectedAnnounce.category = categories.PNConnectedCategory; + connectedAnnounce.operation = status.operation; + connectedAnnounce.affectedChannels = this._pendingChannelSubscriptions; + connectedAnnounce.subscribedChannels = this.getSubscribedChannels(); + connectedAnnounce.affectedChannelGroups = this._pendingChannelGroupSubscriptions; + connectedAnnounce.lastTimetoken = this._lastTimetoken; + connectedAnnounce.currentTimetoken = this._currentTimetoken; + this._subscriptionStatusAnnounced = true; + this._listenerManager.announceStatus(connectedAnnounce); + // clear the pending connections list + this._pendingChannelSubscriptions = []; + this._pendingChannelGroupSubscriptions = []; + } + var messages = payload.messages || []; + var _a = this._config, requestMessageCountThreshold = _a.requestMessageCountThreshold, dedupeOnSubscribe = _a.dedupeOnSubscribe; + if (requestMessageCountThreshold && messages.length >= requestMessageCountThreshold) { + var countAnnouncement = {}; + countAnnouncement.category = categories.PNRequestMessageCountExceededCategory; + countAnnouncement.operation = status.operation; + this._listenerManager.announceStatus(countAnnouncement); + } + messages.forEach(function (message) { + var channel = message.channel; + var subscriptionMatch = message.subscriptionMatch; + var publishMetaData = message.publishMetaData; + if (channel === subscriptionMatch) { + subscriptionMatch = null; + } + if (dedupeOnSubscribe) { + if (_this._dedupingManager.isDuplicate(message)) { + return; + } + _this._dedupingManager.addEntry(message); + } + if (utils$5.endsWith(message.channel, '-pnpres')) { + var announce = {}; + announce.channel = null; + announce.subscription = null; + // deprecated --> + announce.actualChannel = subscriptionMatch != null ? channel : null; + announce.subscribedChannel = subscriptionMatch != null ? subscriptionMatch : channel; + // <-- deprecated + if (channel) { + announce.channel = channel.substring(0, channel.lastIndexOf('-pnpres')); + } + if (subscriptionMatch) { + announce.subscription = subscriptionMatch.substring(0, subscriptionMatch.lastIndexOf('-pnpres')); + } + announce.action = message.payload.action; + announce.state = message.payload.data; + announce.timetoken = publishMetaData.publishTimetoken; + announce.occupancy = message.payload.occupancy; + announce.uuid = message.payload.uuid; + announce.timestamp = message.payload.timestamp; + if (message.payload.join) { + announce.join = message.payload.join; + } + if (message.payload.leave) { + announce.leave = message.payload.leave; + } + if (message.payload.timeout) { + announce.timeout = message.payload.timeout; + } + _this._listenerManager.announcePresence(announce); + } + else if (message.messageType === 1) { + // this is a signal message + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = message.issuingClientId; + if (message.userMetadata) { + announce.userMetadata = message.userMetadata; + } + announce.message = message.payload; + _this._listenerManager.announceSignal(announce); + } + else if (message.messageType === 2) { + // this is an object message + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = message.issuingClientId; + if (message.userMetadata) { + announce.userMetadata = message.userMetadata; + } + announce.message = { + event: message.payload.event, + type: message.payload.type, + data: message.payload.data, + }; + _this._listenerManager.announceObjects(announce); + if (message.payload.type === 'uuid') { + var eventData = _this._renameChannelField(announce); + _this._listenerManager.announceUser(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), type: 'user' }) })); + } + else if (message.payload.type === 'channel') { + var eventData = _this._renameChannelField(announce); + _this._listenerManager.announceSpace(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), type: 'space' }) })); + } + else if (message.payload.type === 'membership') { + var eventData = _this._renameChannelField(announce); + var _a = eventData.message.data, user = _a.uuid, space = _a.channel, membershipData = __rest(_a, ["uuid", "channel"]); + membershipData.user = user; + membershipData.space = space; + _this._listenerManager.announceMembership(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), data: membershipData }) })); + } + } + else if (message.messageType === 3) { + // this is a message action + var announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = message.issuingClientId; + announce.data = { + messageTimetoken: message.payload.data.messageTimetoken, + actionTimetoken: message.payload.data.actionTimetoken, + type: message.payload.data.type, + uuid: message.issuingClientId, + value: message.payload.data.value, + }; + announce.event = message.payload.event; + _this._listenerManager.announceMessageAction(announce); + } + else if (message.messageType === 4) { + // this is a file message + var announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = message.issuingClientId; + var msgPayload = message.payload; + if (_this._config.cipherKey) { + var decryptedPayload = _this._crypto.decrypt(message.payload); + if (typeof decryptedPayload === 'object' && decryptedPayload !== null) { + msgPayload = decryptedPayload; + } + } + if (message.userMetadata) { + announce.userMetadata = message.userMetadata; + } + announce.message = msgPayload.message; + announce.file = { + id: msgPayload.file.id, + name: msgPayload.file.name, + url: _this._getFileUrl({ + id: msgPayload.file.id, + name: msgPayload.file.name, + channel: channel, + }), + }; + _this._listenerManager.announceFile(announce); + } + else { + var announce = {}; + announce.channel = null; + announce.subscription = null; + // deprecated --> + announce.actualChannel = subscriptionMatch != null ? channel : null; + announce.subscribedChannel = subscriptionMatch != null ? subscriptionMatch : channel; + // <-- deprecated + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = message.issuingClientId; + if (message.userMetadata) { + announce.userMetadata = message.userMetadata; + } + if (_this._config.cipherKey) { + announce.message = _this._crypto.decrypt(message.payload); + } + else { + announce.message = message.payload; + } + _this._listenerManager.announceMessage(announce); + } + }); + this._region = payload.metadata.region; + this._startSubscribeLoop(); + }; + default_1.prototype._stopSubscribeLoop = function () { + if (this._subscribeCall) { + if (typeof this._subscribeCall.abort === 'function') { + this._subscribeCall.abort(); + } + this._subscribeCall = null; + } + }; + default_1.prototype._renameEvent = function (e) { + return e === 'set' ? 'updated' : 'removed'; + }; + default_1.prototype._renameChannelField = function (announce) { + var channel = announce.channel, eventData = __rest(announce, ["channel"]); + eventData.spaceId = channel; + return eventData; + }; + return default_1; + }()); + + /* */ + var OPERATIONS = { + PNTimeOperation: 'PNTimeOperation', + PNHistoryOperation: 'PNHistoryOperation', + PNDeleteMessagesOperation: 'PNDeleteMessagesOperation', + PNFetchMessagesOperation: 'PNFetchMessagesOperation', + PNMessageCounts: 'PNMessageCountsOperation', + // pubsub + PNSubscribeOperation: 'PNSubscribeOperation', + PNUnsubscribeOperation: 'PNUnsubscribeOperation', + PNPublishOperation: 'PNPublishOperation', + PNSignalOperation: 'PNSignalOperation', + // Actions API + PNAddMessageActionOperation: 'PNAddActionOperation', + PNRemoveMessageActionOperation: 'PNRemoveMessageActionOperation', + PNGetMessageActionsOperation: 'PNGetMessageActionsOperation', + // Objects API + PNCreateUserOperation: 'PNCreateUserOperation', + PNUpdateUserOperation: 'PNUpdateUserOperation', + PNDeleteUserOperation: 'PNDeleteUserOperation', + PNGetUserOperation: 'PNGetUsersOperation', + PNGetUsersOperation: 'PNGetUsersOperation', + PNCreateSpaceOperation: 'PNCreateSpaceOperation', + PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', + PNDeleteSpaceOperation: 'PNDeleteSpaceOperation', + PNGetSpaceOperation: 'PNGetSpacesOperation', + PNGetSpacesOperation: 'PNGetSpacesOperation', + PNGetMembersOperation: 'PNGetMembersOperation', + PNUpdateMembersOperation: 'PNUpdateMembersOperation', + PNGetMembershipsOperation: 'PNGetMembershipsOperation', + PNUpdateMembershipsOperation: 'PNUpdateMembershipsOperation', + // File Upload API v1 + PNListFilesOperation: 'PNListFilesOperation', + PNGenerateUploadUrlOperation: 'PNGenerateUploadUrlOperation', + PNPublishFileOperation: 'PNPublishFileOperation', + PNGetFileUrlOperation: 'PNGetFileUrlOperation', + PNDownloadFileOperation: 'PNDownloadFileOperation', + // Objects API v2 + // UUID + PNGetAllUUIDMetadataOperation: 'PNGetAllUUIDMetadataOperation', + PNGetUUIDMetadataOperation: 'PNGetUUIDMetadataOperation', + PNSetUUIDMetadataOperation: 'PNSetUUIDMetadataOperation', + PNRemoveUUIDMetadataOperation: 'PNRemoveUUIDMetadataOperation', + // channel + PNGetAllChannelMetadataOperation: 'PNGetAllChannelMetadataOperation', + PNGetChannelMetadataOperation: 'PNGetChannelMetadataOperation', + PNSetChannelMetadataOperation: 'PNSetChannelMetadataOperation', + PNRemoveChannelMetadataOperation: 'PNRemoveChannelMetadataOperation', + // member + // PNGetMembersOperation: 'PNGetMembersOperation', + PNSetMembersOperation: 'PNSetMembersOperation', + // PNGetMembershipsOperation: 'PNGetMembersOperation', + PNSetMembershipsOperation: 'PNSetMembershipsOperation', + // push + PNPushNotificationEnabledChannelsOperation: 'PNPushNotificationEnabledChannelsOperation', + PNRemoveAllPushNotificationsOperation: 'PNRemoveAllPushNotificationsOperation', + // + // presence + PNWhereNowOperation: 'PNWhereNowOperation', + PNSetStateOperation: 'PNSetStateOperation', + PNHereNowOperation: 'PNHereNowOperation', + PNGetStateOperation: 'PNGetStateOperation', + PNHeartbeatOperation: 'PNHeartbeatOperation', + // + // channel group + PNChannelGroupsOperation: 'PNChannelGroupsOperation', + PNRemoveGroupOperation: 'PNRemoveGroupOperation', + PNChannelsForGroupOperation: 'PNChannelsForGroupOperation', + PNAddChannelsToGroupOperation: 'PNAddChannelsToGroupOperation', + PNRemoveChannelsFromGroupOperation: 'PNRemoveChannelsFromGroupOperation', + // + // PAM + PNAccessManagerGrant: 'PNAccessManagerGrant', + PNAccessManagerGrantToken: 'PNAccessManagerGrantToken', + PNAccessManagerAudit: 'PNAccessManagerAudit', + PNAccessManagerRevokeToken: 'PNAccessManagerRevokeToken', + // + // subscription utilities + PNHandshakeOperation: 'PNHandshakeOperation', + PNReceiveMessagesOperation: 'PNReceiveMessagesOperation', + }; + + /* */ + var default_1$6 = /** @class */ (function () { + function default_1(configuration) { + this._maximumSamplesCount = 100; + this._trackedLatencies = {}; + this._latencies = {}; + this._maximumSamplesCount = configuration.maximumSamplesCount || this._maximumSamplesCount; + } + /** + * Compose object with latency information of recently used API endpoints. + * + * @return {Object} Object with request query key/value pairs. + */ + default_1.prototype.operationsLatencyForRequest = function () { + var _this = this; + var latencies = {}; + Object.keys(this._latencies).forEach(function (endpointName) { + var operationLatencies = _this._latencies[endpointName]; + var averageLatency = _this._averageLatency(operationLatencies); + if (averageLatency > 0) { + latencies["l_".concat(endpointName)] = averageLatency; + } + }); + return latencies; + }; + default_1.prototype.startLatencyMeasure = function (operationType, identifier) { + if (operationType === OPERATIONS.PNSubscribeOperation || !identifier) { + return; + } + this._trackedLatencies[identifier] = Date.now(); + }; + default_1.prototype.stopLatencyMeasure = function (operationType, identifier) { + if (operationType === OPERATIONS.PNSubscribeOperation || !identifier) { + return; + } + var endpointName = this._endpointName(operationType); + /** @type Array */ + var endpointLatencies = this._latencies[endpointName]; + var startDate = this._trackedLatencies[identifier]; + if (!endpointLatencies) { + this._latencies[endpointName] = []; + endpointLatencies = this._latencies[endpointName]; + } + endpointLatencies.push(Date.now() - startDate); + // Truncate samples count if there is more then configured. + if (endpointLatencies.length > this._maximumSamplesCount) { + endpointLatencies.splice(0, endpointLatencies.length - this._maximumSamplesCount); + } + delete this._trackedLatencies[identifier]; + }; + default_1.prototype._averageLatency = function (latencies) { + var arrayReduce = function (accumulatedLatency, latency) { return accumulatedLatency + latency; }; + return Math.floor(latencies.reduce(arrayReduce, 0) / latencies.length); + }; + default_1.prototype._endpointName = function (operationType) { + var operation = null; + switch (operationType) { + case OPERATIONS.PNPublishOperation: + operation = 'pub'; + break; + case OPERATIONS.PNSignalOperation: + operation = 'sig'; + break; + case OPERATIONS.PNHistoryOperation: + case OPERATIONS.PNFetchMessagesOperation: + case OPERATIONS.PNDeleteMessagesOperation: + case OPERATIONS.PNMessageCounts: + operation = 'hist'; + break; + case OPERATIONS.PNUnsubscribeOperation: + case OPERATIONS.PNWhereNowOperation: + case OPERATIONS.PNHereNowOperation: + case OPERATIONS.PNHeartbeatOperation: + case OPERATIONS.PNSetStateOperation: + case OPERATIONS.PNGetStateOperation: + operation = 'pres'; + break; + case OPERATIONS.PNAddChannelsToGroupOperation: + case OPERATIONS.PNRemoveChannelsFromGroupOperation: + case OPERATIONS.PNChannelGroupsOperation: + case OPERATIONS.PNRemoveGroupOperation: + case OPERATIONS.PNChannelsForGroupOperation: + operation = 'cg'; + break; + case OPERATIONS.PNPushNotificationEnabledChannelsOperation: + case OPERATIONS.PNRemoveAllPushNotificationsOperation: + operation = 'push'; + break; + case OPERATIONS.PNCreateUserOperation: + case OPERATIONS.PNUpdateUserOperation: + case OPERATIONS.PNDeleteUserOperation: + case OPERATIONS.PNGetUserOperation: + case OPERATIONS.PNGetUsersOperation: + case OPERATIONS.PNCreateSpaceOperation: + case OPERATIONS.PNUpdateSpaceOperation: + case OPERATIONS.PNDeleteSpaceOperation: + case OPERATIONS.PNGetSpaceOperation: + case OPERATIONS.PNGetSpacesOperation: + case OPERATIONS.PNGetMembersOperation: + case OPERATIONS.PNUpdateMembersOperation: + case OPERATIONS.PNGetMembershipsOperation: + case OPERATIONS.PNUpdateMembershipsOperation: + operation = 'obj'; + break; + case OPERATIONS.PNAddMessageActionOperation: + case OPERATIONS.PNRemoveMessageActionOperation: + case OPERATIONS.PNGetMessageActionsOperation: + operation = 'msga'; + break; + case OPERATIONS.PNAccessManagerGrant: + case OPERATIONS.PNAccessManagerAudit: + operation = 'pam'; + break; + case OPERATIONS.PNAccessManagerGrantToken: + case OPERATIONS.PNAccessManagerRevokeToken: + operation = 'pamv3'; + break; + default: + operation = 'time'; + break; + } + return operation; + }; + return default_1; + }()); + + var BaseNotificationPayload = /** @class */ (function () { + function BaseNotificationPayload(payload, title, body) { + this._payload = payload; + this._setDefaultPayloadStructure(); + this.title = title; + this.body = body; + } + Object.defineProperty(BaseNotificationPayload.prototype, "payload", { + get: function () { + return this._payload; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(BaseNotificationPayload.prototype, "title", { + set: function (value) { + this._title = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(BaseNotificationPayload.prototype, "subtitle", { + set: function (value) { + this._subtitle = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(BaseNotificationPayload.prototype, "body", { + set: function (value) { + this._body = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(BaseNotificationPayload.prototype, "badge", { + set: function (value) { + this._badge = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(BaseNotificationPayload.prototype, "sound", { + set: function (value) { + this._sound = value; + }, + enumerable: false, + configurable: true + }); + BaseNotificationPayload.prototype._setDefaultPayloadStructure = function () { + // Empty. + }; + BaseNotificationPayload.prototype.toObject = function () { + return {}; + }; + return BaseNotificationPayload; + }()); + var APNSNotificationPayload = /** @class */ (function (_super) { + __extends(APNSNotificationPayload, _super); + function APNSNotificationPayload() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(APNSNotificationPayload.prototype, "configurations", { + set: function (value) { + if (!value || !value.length) + return; + this._configurations = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(APNSNotificationPayload.prototype, "notification", { + get: function () { + return this._payload.aps; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(APNSNotificationPayload.prototype, "title", { + get: function () { + return this._title; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.aps.alert.title = value; + this._title = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(APNSNotificationPayload.prototype, "subtitle", { + get: function () { + return this._subtitle; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.aps.alert.subtitle = value; + this._subtitle = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(APNSNotificationPayload.prototype, "body", { + get: function () { + return this._body; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.aps.alert.body = value; + this._body = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(APNSNotificationPayload.prototype, "badge", { + get: function () { + return this._badge; + }, + set: function (value) { + if (value === undefined || value === null) + return; + this._payload.aps.badge = value; + this._badge = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(APNSNotificationPayload.prototype, "sound", { + get: function () { + return this._sound; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.aps.sound = value; + this._sound = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(APNSNotificationPayload.prototype, "silent", { + set: function (value) { + this._isSilent = value; + }, + enumerable: false, + configurable: true + }); + APNSNotificationPayload.prototype._setDefaultPayloadStructure = function () { + this._payload.aps = { alert: {} }; + }; + APNSNotificationPayload.prototype.toObject = function () { + var _this = this; + var payload = __assign({}, this._payload); + /** @type {{alert: Object, badge: number, sound: string}} */ + var aps = payload.aps; + var alert = aps.alert; + if (this._isSilent) { + aps['content-available'] = 1; + } + if (this._apnsPushType === 'apns2') { + if (!this._configurations || !this._configurations.length) { + throw new ReferenceError('APNS2 configuration is missing'); + } + var configurations_1 = []; + this._configurations.forEach(function (configuration) { + configurations_1.push(_this._objectFromAPNS2Configuration(configuration)); + }); + if (configurations_1.length) { + payload.pn_push = configurations_1; + } + } + if (!alert || !Object.keys(alert).length) { + delete aps.alert; + } + if (this._isSilent) { + delete aps.alert; + delete aps.badge; + delete aps.sound; + alert = {}; + } + return this._isSilent || Object.keys(alert).length ? payload : null; + }; + APNSNotificationPayload.prototype._objectFromAPNS2Configuration = function (configuration) { + var _this = this; + if (!configuration.targets || !configuration.targets.length) { + throw new ReferenceError('At least one APNS2 target should be provided'); + } + var targets = []; + configuration.targets.forEach(function (target) { + targets.push(_this._objectFromAPNSTarget(target)); + }); + var collapseId = configuration.collapseId, expirationDate = configuration.expirationDate; + var objectifiedConfiguration = { auth_method: 'token', targets: targets, version: 'v2' }; + if (collapseId && collapseId.length) { + objectifiedConfiguration.collapse_id = collapseId; + } + if (expirationDate) { + objectifiedConfiguration.expiration = expirationDate.toISOString(); + } + return objectifiedConfiguration; + }; + APNSNotificationPayload.prototype._objectFromAPNSTarget = function (target) { + if (!target.topic || !target.topic.length) { + throw new TypeError("Target 'topic' undefined."); + } + var topic = target.topic, _a = target.environment, environment = _a === void 0 ? 'development' : _a, _b = target.excludedDevices, excludedDevices = _b === void 0 ? [] : _b; + var objectifiedTarget = { topic: topic, environment: environment }; + if (excludedDevices.length) { + objectifiedTarget.excluded_devices = excludedDevices; + } + return objectifiedTarget; + }; + return APNSNotificationPayload; + }(BaseNotificationPayload)); + var MPNSNotificationPayload = /** @class */ (function (_super) { + __extends(MPNSNotificationPayload, _super); + function MPNSNotificationPayload() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(MPNSNotificationPayload.prototype, "backContent", { + get: function () { + return this._backContent; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.back_content = value; + this._backContent = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MPNSNotificationPayload.prototype, "backTitle", { + get: function () { + return this._backTitle; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.back_title = value; + this._backTitle = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MPNSNotificationPayload.prototype, "count", { + get: function () { + return this._count; + }, + set: function (value) { + if (value === undefined || value === null) + return; + this._payload.count = value; + this._count = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MPNSNotificationPayload.prototype, "title", { + get: function () { + return this._title; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.title = value; + this._title = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MPNSNotificationPayload.prototype, "type", { + get: function () { + return this._type; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.type = value; + this._type = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MPNSNotificationPayload.prototype, "subtitle", { + get: function () { + return this.backTitle; + }, + set: function (value) { + this.backTitle = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MPNSNotificationPayload.prototype, "body", { + get: function () { + return this.backContent; + }, + set: function (value) { + this.backContent = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(MPNSNotificationPayload.prototype, "badge", { + get: function () { + return this.count; + }, + set: function (value) { + this.count = value; + }, + enumerable: false, + configurable: true + }); + MPNSNotificationPayload.prototype.toObject = function () { + return Object.keys(this._payload).length ? __assign({}, this._payload) : null; + }; + return MPNSNotificationPayload; + }(BaseNotificationPayload)); + var FCMNotificationPayload = /** @class */ (function (_super) { + __extends(FCMNotificationPayload, _super); + function FCMNotificationPayload() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(FCMNotificationPayload.prototype, "notification", { + get: function () { + return this._payload.notification; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FCMNotificationPayload.prototype, "data", { + get: function () { + return this._payload.data; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FCMNotificationPayload.prototype, "title", { + get: function () { + return this._title; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.notification.title = value; + this._title = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FCMNotificationPayload.prototype, "body", { + get: function () { + return this._body; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.notification.body = value; + this._body = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FCMNotificationPayload.prototype, "sound", { + get: function () { + return this._sound; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.notification.sound = value; + this._sound = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FCMNotificationPayload.prototype, "icon", { + get: function () { + return this._icon; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.notification.icon = value; + this._icon = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FCMNotificationPayload.prototype, "tag", { + get: function () { + return this._tag; + }, + set: function (value) { + if (!value || !value.length) + return; + this._payload.notification.tag = value; + this._tag = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(FCMNotificationPayload.prototype, "silent", { + set: function (value) { + this._isSilent = value; + }, + enumerable: false, + configurable: true + }); + FCMNotificationPayload.prototype._setDefaultPayloadStructure = function () { + this._payload.notification = {}; + this._payload.data = {}; + }; + FCMNotificationPayload.prototype.toObject = function () { + var data = __assign({}, this._payload.data); + var notification = null; + var payload = {}; + /** + * Check whether additional data has been passed outside of 'data' object + * and put it into it if required. + */ + if (Object.keys(this._payload).length > 2) { + var _a = this._payload; _a.notification; _a.data; var additionalData = __rest(_a, ["notification", "data"]); + data = __assign(__assign({}, data), additionalData); + } + if (this._isSilent) { + data.notification = this._payload.notification; + } + else { + notification = this._payload.notification; + } + if (Object.keys(data).length) { + payload.data = data; + } + if (notification && Object.keys(notification).length) { + payload.notification = notification; + } + return Object.keys(payload).length ? payload : null; + }; + return FCMNotificationPayload; + }(BaseNotificationPayload)); + var NotificationsPayload = /** @class */ (function () { + function NotificationsPayload(title, body) { + this._payload = { apns: {}, mpns: {}, fcm: {} }; + this._title = title; + this._body = body; + this.apns = new APNSNotificationPayload(this._payload.apns, title, body); + this.mpns = new MPNSNotificationPayload(this._payload.mpns, title, body); + this.fcm = new FCMNotificationPayload(this._payload.fcm, title, body); + } + Object.defineProperty(NotificationsPayload.prototype, "debugging", { + set: function (value) { + this._debugging = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(NotificationsPayload.prototype, "title", { + get: function () { + return this._title; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(NotificationsPayload.prototype, "body", { + get: function () { + return this._body; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(NotificationsPayload.prototype, "subtitle", { + get: function () { + return this._subtitle; + }, + set: function (value) { + this._subtitle = value; + this.apns.subtitle = value; + this.mpns.subtitle = value; + this.fcm.subtitle = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(NotificationsPayload.prototype, "badge", { + get: function () { + return this._badge; + }, + set: function (value) { + this._badge = value; + this.apns.badge = value; + this.mpns.badge = value; + this.fcm.badge = value; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(NotificationsPayload.prototype, "sound", { + get: function () { + return this._sound; + }, + set: function (value) { + this._sound = value; + this.apns.sound = value; + this.mpns.sound = value; + this.fcm.sound = value; + }, + enumerable: false, + configurable: true + }); + /** + * Build notifications platform for requested platforms. + * + * @param {Array} platforms - List of platforms for which payload + * should be added to final dictionary. Supported values: gcm, apns, apns2, + * mpns. + * + * @returns {Object} Object with data, which can be sent with publish method + * call and trigger remote notifications for specified platforms. + */ + NotificationsPayload.prototype.buildPayload = function (platforms) { + var payload = {}; + if (platforms.includes('apns') || platforms.includes('apns2')) { + this.apns._apnsPushType = platforms.includes('apns') ? 'apns' : 'apns2'; + var apnsPayload = this.apns.toObject(); + if (apnsPayload && Object.keys(apnsPayload).length) { + payload.pn_apns = apnsPayload; + } + } + if (platforms.includes('mpns')) { + var mpnsPayload = this.mpns.toObject(); + if (mpnsPayload && Object.keys(mpnsPayload).length) { + payload.pn_mpns = mpnsPayload; + } + } + if (platforms.includes('fcm')) { + var fcmPayload = this.fcm.toObject(); + if (fcmPayload && Object.keys(fcmPayload).length) { + payload.pn_gcm = fcmPayload; + } + } + if (Object.keys(payload).length && this._debugging) { + payload.pn_debug = true; + } + return payload; + }; + return NotificationsPayload; + }()); + + var default_1$5 = /** @class */ (function () { + function default_1() { + this._listeners = []; + } + default_1.prototype.addListener = function (newListeners) { + this._listeners.push(newListeners); + }; + default_1.prototype.removeListener = function (deprecatedListener) { + var newListeners = []; + this._listeners.forEach(function (listener) { + if (listener !== deprecatedListener) + newListeners.push(listener); + }); + this._listeners = newListeners; + }; + default_1.prototype.removeAllListeners = function () { + this._listeners = []; + }; + default_1.prototype.announcePresence = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.presence) + listener.presence(announce); + }); + }; + default_1.prototype.announceStatus = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.status) + listener.status(announce); + }); + }; + default_1.prototype.announceMessage = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.message) + listener.message(announce); + }); + }; + default_1.prototype.announceSignal = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.signal) + listener.signal(announce); + }); + }; + default_1.prototype.announceMessageAction = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.messageAction) + listener.messageAction(announce); + }); + }; + default_1.prototype.announceFile = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.file) + listener.file(announce); + }); + }; + default_1.prototype.announceObjects = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.objects) + listener.objects(announce); + }); + }; + default_1.prototype.announceUser = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.user) + listener.user(announce); + }); + }; + default_1.prototype.announceSpace = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.space) + listener.space(announce); + }); + }; + default_1.prototype.announceMembership = function (announce) { + this._listeners.forEach(function (listener) { + if (listener.membership) + listener.membership(announce); + }); + }; + default_1.prototype.announceNetworkUp = function () { + var networkStatus = {}; + networkStatus.category = categories.PNNetworkUpCategory; + this.announceStatus(networkStatus); + }; + default_1.prototype.announceNetworkDown = function () { + var networkStatus = {}; + networkStatus.category = categories.PNNetworkDownCategory; + this.announceStatus(networkStatus); + }; + return default_1; + }()); + + var default_1$4 = /** @class */ (function () { + function default_1(config, cbor) { + this._config = config; + this._cbor = cbor; + } + default_1.prototype.setToken = function (token) { + if (token && token.length > 0) { + this._token = token; + } + else { + this._token = undefined; + } + }; + default_1.prototype.getToken = function () { + return this._token; + }; + default_1.prototype.extractPermissions = function (permissions) { + var permissionsResult = { + read: false, + write: false, + manage: false, + delete: false, + get: false, + update: false, + join: false, + }; + /* eslint-disable */ + if ((permissions & 128) === 128) { + permissionsResult.join = true; + } + if ((permissions & 64) === 64) { + permissionsResult.update = true; + } + if ((permissions & 32) === 32) { + permissionsResult.get = true; + } + if ((permissions & 8) === 8) { + permissionsResult.delete = true; + } + if ((permissions & 4) === 4) { + permissionsResult.manage = true; + } + if ((permissions & 2) === 2) { + permissionsResult.write = true; + } + if ((permissions & 1) === 1) { + permissionsResult.read = true; + } + /* eslint-enable */ + return permissionsResult; + }; + default_1.prototype.parseToken = function (tokenString) { + var _this = this; + var parsed = this._cbor.decodeToken(tokenString); + if (parsed !== undefined) { + var uuidResourcePermissions = parsed.res.uuid ? Object.keys(parsed.res.uuid) : []; + var channelResourcePermissions = Object.keys(parsed.res.chan); + var groupResourcePermissions = Object.keys(parsed.res.grp); + var uuidPatternPermissions = parsed.pat.uuid ? Object.keys(parsed.pat.uuid) : []; + var channelPatternPermissions = Object.keys(parsed.pat.chan); + var groupPatternPermissions = Object.keys(parsed.pat.grp); + var result_1 = { + version: parsed.v, + timestamp: parsed.t, + ttl: parsed.ttl, + authorized_uuid: parsed.uuid, + }; + var uuidResources = uuidResourcePermissions.length > 0; + var channelResources = channelResourcePermissions.length > 0; + var groupResources = groupResourcePermissions.length > 0; + if (uuidResources || channelResources || groupResources) { + result_1.resources = {}; + if (uuidResources) { + result_1.resources.uuids = {}; + uuidResourcePermissions.forEach(function (id) { + result_1.resources.uuids[id] = _this.extractPermissions(parsed.res.uuid[id]); + }); + } + if (channelResources) { + result_1.resources.channels = {}; + channelResourcePermissions.forEach(function (id) { + result_1.resources.channels[id] = _this.extractPermissions(parsed.res.chan[id]); + }); + } + if (groupResources) { + result_1.resources.groups = {}; + groupResourcePermissions.forEach(function (id) { + result_1.resources.groups[id] = _this.extractPermissions(parsed.res.grp[id]); + }); + } + } + var uuidPatterns = uuidPatternPermissions.length > 0; + var channelPatterns = channelPatternPermissions.length > 0; + var groupPatterns = groupPatternPermissions.length > 0; + if (uuidPatterns || channelPatterns || groupPatterns) { + result_1.patterns = {}; + if (uuidPatterns) { + result_1.patterns.uuids = {}; + uuidPatternPermissions.forEach(function (id) { + result_1.patterns.uuids[id] = _this.extractPermissions(parsed.pat.uuid[id]); + }); + } + if (channelPatterns) { + result_1.patterns.channels = {}; + channelPatternPermissions.forEach(function (id) { + result_1.patterns.channels[id] = _this.extractPermissions(parsed.pat.chan[id]); + }); + } + if (groupPatterns) { + result_1.patterns.groups = {}; + groupPatternPermissions.forEach(function (id) { + result_1.patterns.groups[id] = _this.extractPermissions(parsed.pat.grp[id]); + }); + } + } + if (Object.keys(parsed.meta).length > 0) { + result_1.meta = parsed.meta; + } + result_1.signature = parsed.sig; + return result_1; + } + return undefined; + }; + return default_1; + }()); + + var PubNubError = /** @class */ (function (_super) { + __extends(PubNubError, _super); + function PubNubError(message, status) { + var _newTarget = this.constructor; + var _this = _super.call(this, message) || this; + _this.name = _this.constructor.name; + _this.status = status; + _this.message = message; + Object.setPrototypeOf(_this, _newTarget.prototype); + return _this; + } + return PubNubError; + }(Error)); + function createError(errorPayload, type) { + errorPayload.type = type; + errorPayload.error = true; + return errorPayload; + } + function createValidationError(message) { + return createError({ message: message }, 'validationError'); + } + function decideURL(endpoint, modules, incomingParams) { + if (endpoint.usePost && endpoint.usePost(modules, incomingParams)) { + return endpoint.postURL(modules, incomingParams); + } + if (endpoint.usePatch && endpoint.usePatch(modules, incomingParams)) { + return endpoint.patchURL(modules, incomingParams); + } + if (endpoint.useGetFile && endpoint.useGetFile(modules, incomingParams)) { + return endpoint.getFileURL(modules, incomingParams); + } + return endpoint.getURL(modules, incomingParams); + } + function generatePNSDK(config) { + if (config.sdkName) { + return config.sdkName; + } + var base = "PubNub-JS-".concat(config.sdkFamily); + if (config.partnerId) { + base += "-".concat(config.partnerId); + } + base += "/".concat(config.getVersion()); + var pnsdkSuffix = config._getPnsdkSuffix(' '); + if (pnsdkSuffix.length > 0) { + base += pnsdkSuffix; + } + return base; + } + function getHttpMethod(modules, endpoint, incomingParams) { + if (endpoint.usePost && endpoint.usePost(modules, incomingParams)) { + return 'POST'; + } + if (endpoint.usePatch && endpoint.usePatch(modules, incomingParams)) { + return 'PATCH'; + } + if (endpoint.useDelete && endpoint.useDelete(modules, incomingParams)) { + return 'DELETE'; + } + if (endpoint.useGetFile && endpoint.useGetFile(modules, incomingParams)) { + return 'GETFILE'; + } + return 'GET'; + } + function signRequest(modules, url, outgoingParams, incomingParams, endpoint) { + var config = modules.config, crypto = modules.crypto; + var httpMethod = getHttpMethod(modules, endpoint, incomingParams); + outgoingParams.timestamp = Math.floor(new Date().getTime() / 1000); + // This is because of a server-side bug, old publish using post should be deprecated + if (endpoint.getOperation() === 'PNPublishOperation' && + endpoint.usePost && + endpoint.usePost(modules, incomingParams)) { + httpMethod = 'GET'; + } + if (httpMethod === 'GETFILE') { + httpMethod = 'GET'; + } + var signInput = "".concat(httpMethod, "\n").concat(config.publishKey, "\n").concat(url, "\n").concat(utils$5.signPamFromParams(outgoingParams), "\n"); + if (httpMethod === 'POST') { + var payload = endpoint.postPayload(modules, incomingParams); + if (typeof payload === 'string') { + signInput += payload; + } + else { + signInput += JSON.stringify(payload); + } + } + else if (httpMethod === 'PATCH') { + var payload = endpoint.patchPayload(modules, incomingParams); + if (typeof payload === 'string') { + signInput += payload; + } + else { + signInput += JSON.stringify(payload); + } + } + var signature = "v2.".concat(crypto.HMACSHA256(signInput)); + signature = signature.replace(/\+/g, '-'); + signature = signature.replace(/\//g, '_'); + signature = signature.replace(/=+$/, ''); + outgoingParams.signature = signature; + } + function endpointCreator (modules, endpoint) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + var networking = modules.networking, config = modules.config, telemetryManager = modules.telemetryManager, tokenManager = modules.tokenManager; + var requestId = uuidGenerator.createUUID(); + var callback = null; + var promiseComponent = null; + var incomingParams = {}; + if (endpoint.getOperation() === OPERATIONS.PNTimeOperation || + endpoint.getOperation() === OPERATIONS.PNChannelGroupsOperation) { + callback = args[0]; + } + else { + incomingParams = args[0]; + callback = args[1]; + } + // bridge in Promise support. + if (typeof Promise !== 'undefined' && !callback) { + promiseComponent = utils$5.createPromise(); + } + var validationResult = endpoint.validateParams(modules, incomingParams); + if (validationResult) { + if (callback) { + return callback(createValidationError(validationResult)); + } + if (promiseComponent) { + promiseComponent.reject(new PubNubError('Validation failed, check status for details', createValidationError(validationResult))); + return promiseComponent.promise; + } + return; + } + var outgoingParams = endpoint.prepareParams(modules, incomingParams); + var url = decideURL(endpoint, modules, incomingParams); + var callInstance; + var networkingParams = { + url: url, + operation: endpoint.getOperation(), + timeout: endpoint.getRequestTimeout(modules), + headers: endpoint.getRequestHeaders ? endpoint.getRequestHeaders() : {}, + ignoreBody: typeof endpoint.ignoreBody === 'function' ? endpoint.ignoreBody(modules) : false, + forceBuffered: typeof endpoint.forceBuffered === 'function' ? endpoint.forceBuffered(modules, incomingParams) : null, + abortSignal: typeof endpoint.getAbortSignal === 'function' ? endpoint.getAbortSignal(modules, incomingParams) : null, + }; + outgoingParams.uuid = config.UUID; + outgoingParams.pnsdk = generatePNSDK(config); + // Add telemetry information (if there is any available). + var telemetryLatencies = telemetryManager.operationsLatencyForRequest(); + if (Object.keys(telemetryLatencies).length) { + outgoingParams = __assign(__assign({}, outgoingParams), telemetryLatencies); + } + if (config.useInstanceId) { + outgoingParams.instanceid = config.instanceId; + } + if (config.useRequestId) { + outgoingParams.requestid = requestId; + } + if (endpoint.isAuthSupported()) { + var tokenOrKey = tokenManager.getToken() || config.getAuthKey(); + if (tokenOrKey) { + outgoingParams.auth = tokenOrKey; + } + } + if (config.secretKey) { + signRequest(modules, url, outgoingParams, incomingParams, endpoint); + } + var onResponse = function (status, payload) { + if (status.error) { + if (endpoint.handleError) { + endpoint.handleError(modules, incomingParams, status); + } + if (callback) { + callback(status); + } + else if (promiseComponent) { + promiseComponent.reject(new PubNubError('PubNub call failed, check status for details', status)); + } + return; + } + // Stop endpoint latency tracking. + telemetryManager.stopLatencyMeasure(endpoint.getOperation(), requestId); + var responseP = endpoint.handleResponse(modules, payload, incomingParams); + if (typeof (responseP === null || responseP === void 0 ? void 0 : responseP.then) !== 'function') { + responseP = Promise.resolve(responseP); + } + responseP + .then(function (result) { + if (callback) { + callback(status, result); + } + else if (promiseComponent) { + promiseComponent.fulfill(result); + } + }) + .catch(function (e) { + if (callback) { + var errorData = e; + if (endpoint.getOperation() === OPERATIONS.PNSubscribeOperation) { + errorData = { + statusCode: 400, + error: true, + operation: endpoint.getOperation(), + errorData: e, + category: categories.PNUnknownCategory, + }; + } + callback(errorData, null); + } + else if (promiseComponent) { + promiseComponent.reject(new PubNubError('PubNub call failed, check status for details', e)); + } + }); + }; + // Start endpoint latency tracking. + telemetryManager.startLatencyMeasure(endpoint.getOperation(), requestId); + if (getHttpMethod(modules, endpoint, incomingParams) === 'POST') { + var payload = endpoint.postPayload(modules, incomingParams); + callInstance = networking.POST(outgoingParams, payload, networkingParams, onResponse); + } + else if (getHttpMethod(modules, endpoint, incomingParams) === 'PATCH') { + var payload = endpoint.patchPayload(modules, incomingParams); + callInstance = networking.PATCH(outgoingParams, payload, networkingParams, onResponse); + } + else if (getHttpMethod(modules, endpoint, incomingParams) === 'DELETE') { + callInstance = networking.DELETE(outgoingParams, networkingParams, onResponse); + } + else if (getHttpMethod(modules, endpoint, incomingParams) === 'GETFILE') { + callInstance = networking.GETFILE(outgoingParams, networkingParams, onResponse); + } + else { + callInstance = networking.GET(outgoingParams, networkingParams, onResponse); + } + if (endpoint.getOperation() === OPERATIONS.PNSubscribeOperation) { + return callInstance; + } + if (promiseComponent) { + return promiseComponent.promise; + } + } + + /* */ + function getOperation$s() { + return OPERATIONS.PNAddChannelsToGroupOperation; + } + function validateParams$s(modules, incomingParams) { + var channels = incomingParams.channels, channelGroup = incomingParams.channelGroup; + var config = modules.config; + if (!channelGroup) + return 'Missing Channel Group'; + if (!channels || channels.length === 0) + return 'Missing Channels'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$q(modules, incomingParams) { + var channelGroup = incomingParams.channelGroup; + var config = modules.config; + return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup)); + } + function getRequestTimeout$s(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$s() { + return true; + } + function prepareParams$s(modules, incomingParams) { + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; + return { + add: channels.join(','), + }; + } + function handleResponse$s() { + return {}; + } + + var addChannelsChannelGroupConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$s, + validateParams: validateParams$s, + getURL: getURL$q, + getRequestTimeout: getRequestTimeout$s, + isAuthSupported: isAuthSupported$s, + prepareParams: prepareParams$s, + handleResponse: handleResponse$s + }); + + /* */ + function getOperation$r() { + return OPERATIONS.PNRemoveChannelsFromGroupOperation; + } + function validateParams$r(modules, incomingParams) { + var channels = incomingParams.channels, channelGroup = incomingParams.channelGroup; + var config = modules.config; + if (!channelGroup) + return 'Missing Channel Group'; + if (!channels || channels.length === 0) + return 'Missing Channels'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$p(modules, incomingParams) { + var channelGroup = incomingParams.channelGroup; + var config = modules.config; + return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup)); + } + function getRequestTimeout$r(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$r() { + return true; + } + function prepareParams$r(modules, incomingParams) { + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; + return { + remove: channels.join(','), + }; + } + function handleResponse$r() { + return {}; + } + + var removeChannelsChannelGroupConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$r, + validateParams: validateParams$r, + getURL: getURL$p, + getRequestTimeout: getRequestTimeout$r, + isAuthSupported: isAuthSupported$r, + prepareParams: prepareParams$r, + handleResponse: handleResponse$r + }); + + /* */ + function getOperation$q() { + return OPERATIONS.PNRemoveGroupOperation; + } + function validateParams$q(modules, incomingParams) { + var channelGroup = incomingParams.channelGroup; + var config = modules.config; + if (!channelGroup) + return 'Missing Channel Group'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$o(modules, incomingParams) { + var channelGroup = incomingParams.channelGroup; + var config = modules.config; + return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup), "/remove"); + } + function isAuthSupported$q() { + return true; + } + function getRequestTimeout$q(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function prepareParams$q() { + return {}; + } + function handleResponse$q() { + return {}; + } + + var deleteChannelGroupConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$q, + validateParams: validateParams$q, + getURL: getURL$o, + isAuthSupported: isAuthSupported$q, + getRequestTimeout: getRequestTimeout$q, + prepareParams: prepareParams$q, + handleResponse: handleResponse$q + }); + + /* */ + function getOperation$p() { + return OPERATIONS.PNChannelGroupsOperation; + } + function validateParams$p(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$n(modules) { + var config = modules.config; + return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group"); + } + function getRequestTimeout$p(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$p() { + return true; + } + function prepareParams$p() { + return {}; + } + function handleResponse$p(modules, serverResponse) { + return { + groups: serverResponse.payload.groups, + }; + } + + var listChannelGroupsConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$p, + validateParams: validateParams$p, + getURL: getURL$n, + getRequestTimeout: getRequestTimeout$p, + isAuthSupported: isAuthSupported$p, + prepareParams: prepareParams$p, + handleResponse: handleResponse$p + }); + + /* */ + function getOperation$o() { + return OPERATIONS.PNChannelsForGroupOperation; + } + function validateParams$o(modules, incomingParams) { + var channelGroup = incomingParams.channelGroup; + var config = modules.config; + if (!channelGroup) + return 'Missing Channel Group'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$m(modules, incomingParams) { + var channelGroup = incomingParams.channelGroup; + var config = modules.config; + return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup)); + } + function getRequestTimeout$o(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$o() { + return true; + } + function prepareParams$o() { + return {}; + } + function handleResponse$o(modules, serverResponse) { + return { + channels: serverResponse.payload.channels, + }; + } + + var listChannelsInChannelGroupConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$o, + validateParams: validateParams$o, + getURL: getURL$m, + getRequestTimeout: getRequestTimeout$o, + isAuthSupported: isAuthSupported$o, + prepareParams: prepareParams$o, + handleResponse: handleResponse$o + }); + + /* */ + function getOperation$n() { + return OPERATIONS.PNPushNotificationEnabledChannelsOperation; + } + function validateParams$n(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway, channels = incomingParams.channels, topic = incomingParams.topic; + var config = modules.config; + if (!device) + return 'Missing Device ID (device)'; + if (!pushGateway) + return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; + if (pushGateway === 'apns2' && !topic) + return 'Missing APNS2 topic'; + if (!channels || channels.length === 0) + return 'Missing Channels'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$l(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway; + var config = modules.config; + if (pushGateway === 'apns2') { + return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device); + } + return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device); + } + function getRequestTimeout$n(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$n() { + return true; + } + function prepareParams$n(modules, incomingParams) { + var pushGateway = incomingParams.pushGateway, _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.environment, environment = _b === void 0 ? 'development' : _b, topic = incomingParams.topic; + var parameters = { type: pushGateway, add: channels.join(',') }; + if (pushGateway === 'apns2') { + parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); + delete parameters.type; + } + return parameters; + } + function handleResponse$n() { + return {}; + } + + var addPushChannelsConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$n, + validateParams: validateParams$n, + getURL: getURL$l, + getRequestTimeout: getRequestTimeout$n, + isAuthSupported: isAuthSupported$n, + prepareParams: prepareParams$n, + handleResponse: handleResponse$n + }); + + /* */ + function getOperation$m() { + return OPERATIONS.PNPushNotificationEnabledChannelsOperation; + } + function validateParams$m(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway, channels = incomingParams.channels, topic = incomingParams.topic; + var config = modules.config; + if (!device) + return 'Missing Device ID (device)'; + if (!pushGateway) + return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; + if (pushGateway === 'apns2' && !topic) + return 'Missing APNS2 topic'; + if (!channels || channels.length === 0) + return 'Missing Channels'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$k(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway; + var config = modules.config; + if (pushGateway === 'apns2') { + return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device); + } + return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device); + } + function getRequestTimeout$m(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$m() { + return true; + } + function prepareParams$m(modules, incomingParams) { + var pushGateway = incomingParams.pushGateway, _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.environment, environment = _b === void 0 ? 'development' : _b, topic = incomingParams.topic; + var parameters = { type: pushGateway, remove: channels.join(',') }; + if (pushGateway === 'apns2') { + parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); + delete parameters.type; + } + return parameters; + } + function handleResponse$m() { + return {}; + } + + var removePushChannelsConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$m, + validateParams: validateParams$m, + getURL: getURL$k, + getRequestTimeout: getRequestTimeout$m, + isAuthSupported: isAuthSupported$m, + prepareParams: prepareParams$m, + handleResponse: handleResponse$m + }); + + /* */ + function getOperation$l() { + return OPERATIONS.PNPushNotificationEnabledChannelsOperation; + } + function validateParams$l(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway, topic = incomingParams.topic; + var config = modules.config; + if (!device) + return 'Missing Device ID (device)'; + if (!pushGateway) + return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; + if (pushGateway === 'apns2' && !topic) + return 'Missing APNS2 topic'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$j(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway; + var config = modules.config; + if (pushGateway === 'apns2') { + return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device); + } + return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device); + } + function getRequestTimeout$l(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$l() { + return true; + } + function prepareParams$l(modules, incomingParams) { + var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic; + var parameters = { type: pushGateway }; + if (pushGateway === 'apns2') { + parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); + delete parameters.type; + } + return parameters; + } + function handleResponse$l(modules, serverResponse) { + return { channels: serverResponse }; + } + + var listPushChannelsConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$l, + validateParams: validateParams$l, + getURL: getURL$j, + getRequestTimeout: getRequestTimeout$l, + isAuthSupported: isAuthSupported$l, + prepareParams: prepareParams$l, + handleResponse: handleResponse$l + }); + + /* */ + function getOperation$k() { + return OPERATIONS.PNRemoveAllPushNotificationsOperation; + } + function validateParams$k(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway, topic = incomingParams.topic; + var config = modules.config; + if (!device) + return 'Missing Device ID (device)'; + if (!pushGateway) + return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; + if (pushGateway === 'apns2' && !topic) + return 'Missing APNS2 topic'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$i(modules, incomingParams) { + var device = incomingParams.device, pushGateway = incomingParams.pushGateway; + var config = modules.config; + if (pushGateway === 'apns2') { + return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device, "/remove"); + } + return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device, "/remove"); + } + function getRequestTimeout$k(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$k() { + return true; + } + function prepareParams$k(modules, incomingParams) { + var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic; + var parameters = { type: pushGateway }; + if (pushGateway === 'apns2') { + parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); + delete parameters.type; + } + return parameters; + } + function handleResponse$k() { + return {}; + } + + var removeDevicePushConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$k, + validateParams: validateParams$k, + getURL: getURL$i, + getRequestTimeout: getRequestTimeout$k, + isAuthSupported: isAuthSupported$k, + prepareParams: prepareParams$k, + handleResponse: handleResponse$k + }); + + /* */ + function getOperation$j() { + return OPERATIONS.PNUnsubscribeOperation; + } + function validateParams$j(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$h(modules, incomingParams) { + var config = modules.config; + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; + var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; + return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/leave"); + } + function getRequestTimeout$j(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$j() { + return true; + } + function prepareParams$j(modules, incomingParams) { + var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a; + var params = {}; + if (channelGroups.length > 0) { + params['channel-group'] = channelGroups.join(','); + } + return params; + } + function handleResponse$j() { + return {}; + } + + var presenceLeaveEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$j, + validateParams: validateParams$j, + getURL: getURL$h, + getRequestTimeout: getRequestTimeout$j, + isAuthSupported: isAuthSupported$j, + prepareParams: prepareParams$j, + handleResponse: handleResponse$j + }); + + /* */ + function getOperation$i() { + return OPERATIONS.PNWhereNowOperation; + } + function validateParams$i(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$g(modules, incomingParams) { + var config = modules.config; + var _a = incomingParams.uuid, uuid = _a === void 0 ? config.UUID : _a; + return "/v2/presence/sub-key/".concat(config.subscribeKey, "/uuid/").concat(utils$5.encodeString(uuid)); + } + function getRequestTimeout$i(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$i() { + return true; + } + function prepareParams$i() { + return {}; + } + function handleResponse$i(modules, serverResponse) { + // This is a quick fix for when the server does not include a payload + // in where now responses + if (!serverResponse.payload) { + return { channels: [] }; + } + return { channels: serverResponse.payload.channels }; + } + + var presenceWhereNowEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$i, + validateParams: validateParams$i, + getURL: getURL$g, + getRequestTimeout: getRequestTimeout$i, + isAuthSupported: isAuthSupported$i, + prepareParams: prepareParams$i, + handleResponse: handleResponse$i + }); + + /* */ + function getOperation$h() { + return OPERATIONS.PNHeartbeatOperation; + } + function validateParams$h(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$f(modules, incomingParams) { + var config = modules.config; + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; + var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; + return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/heartbeat"); + } + function isAuthSupported$h() { + return true; + } + function getRequestTimeout$h(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function prepareParams$h(modules, incomingParams) { + var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, _b = incomingParams.state, state = _b === void 0 ? {} : _b; + var config = modules.config; + var params = {}; + if (channelGroups.length > 0) { + params['channel-group'] = channelGroups.join(','); + } + params.state = JSON.stringify(state); + params.heartbeat = config.getPresenceTimeout(); + return params; + } + function handleResponse$h() { + return {}; + } + + var presenceHeartbeatEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$h, + validateParams: validateParams$h, + getURL: getURL$f, + isAuthSupported: isAuthSupported$h, + getRequestTimeout: getRequestTimeout$h, + prepareParams: prepareParams$h, + handleResponse: handleResponse$h + }); + + /* */ + function getOperation$g() { + return OPERATIONS.PNGetStateOperation; + } + function validateParams$g(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$e(modules, incomingParams) { + var config = modules.config; + var _a = incomingParams.uuid, uuid = _a === void 0 ? config.UUID : _a, _b = incomingParams.channels, channels = _b === void 0 ? [] : _b; + var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; + return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/uuid/").concat(uuid); + } + function getRequestTimeout$g(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$g() { + return true; + } + function prepareParams$g(modules, incomingParams) { + var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a; + var params = {}; + if (channelGroups.length > 0) { + params['channel-group'] = channelGroups.join(','); + } + return params; + } + function handleResponse$g(modules, serverResponse, incomingParams) { + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b; + var channelsResponse = {}; + if (channels.length === 1 && channelGroups.length === 0) { + channelsResponse[channels[0]] = serverResponse.payload; + } + else { + channelsResponse = serverResponse.payload; + } + return { channels: channelsResponse }; + } + + var presenceGetStateConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$g, + validateParams: validateParams$g, + getURL: getURL$e, + getRequestTimeout: getRequestTimeout$g, + isAuthSupported: isAuthSupported$g, + prepareParams: prepareParams$g, + handleResponse: handleResponse$g + }); + + function getOperation$f() { + return OPERATIONS.PNSetStateOperation; + } + function validateParams$f(modules, incomingParams) { + var config = modules.config; + var state = incomingParams.state, _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b; + if (!state) + return 'Missing State'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + if (channels.length === 0 && channelGroups.length === 0) { + return 'Please provide a list of channels and/or channel-groups'; + } + } + function getURL$d(modules, incomingParams) { + var config = modules.config; + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; + var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; + return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/uuid/").concat(utils$5.encodeString(config.UUID), "/data"); + } + function getRequestTimeout$f(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$f() { + return true; + } + function prepareParams$f(modules, incomingParams) { + var state = incomingParams.state, _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a; + var params = {}; + params.state = JSON.stringify(state); + if (channelGroups.length > 0) { + params['channel-group'] = channelGroups.join(','); + } + return params; + } + function handleResponse$f(modules, serverResponse) { + return { state: serverResponse.payload }; + } + + var presenceSetStateConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$f, + validateParams: validateParams$f, + getURL: getURL$d, + getRequestTimeout: getRequestTimeout$f, + isAuthSupported: isAuthSupported$f, + prepareParams: prepareParams$f, + handleResponse: handleResponse$f + }); + + /* */ + function getOperation$e() { + return OPERATIONS.PNHereNowOperation; + } + function validateParams$e(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$c(modules, incomingParams) { + var config = modules.config; + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b; + var baseURL = "/v2/presence/sub-key/".concat(config.subscribeKey); + if (channels.length > 0 || channelGroups.length > 0) { + var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; + baseURL += "/channel/".concat(utils$5.encodeString(stringifiedChannels)); + } + return baseURL; + } + function getRequestTimeout$e(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$e() { + return true; + } + function prepareParams$e(modules, incomingParams) { + var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, _b = incomingParams.includeUUIDs, includeUUIDs = _b === void 0 ? true : _b, _c = incomingParams.includeState, includeState = _c === void 0 ? false : _c, _d = incomingParams.queryParameters, queryParameters = _d === void 0 ? {} : _d; + var params = {}; + if (!includeUUIDs) + params.disable_uuids = 1; + if (includeState) + params.state = 1; + if (channelGroups.length > 0) { + params['channel-group'] = channelGroups.join(','); + } + params = __assign(__assign({}, params), queryParameters); + return params; + } + function handleResponse$e(modules, serverResponse, incomingParams) { + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = incomingParams.includeUUIDs, includeUUIDs = _c === void 0 ? true : _c, _d = incomingParams.includeState, includeState = _d === void 0 ? false : _d; + var prepareSingularChannel = function () { + var response = {}; + var occupantsList = []; + response.totalChannels = 1; + response.totalOccupancy = serverResponse.occupancy; + response.channels = {}; + response.channels[channels[0]] = { + occupants: occupantsList, + name: channels[0], + occupancy: serverResponse.occupancy, + }; + // We have had issues in the past with server returning responses + // that contain no uuids array + if (includeUUIDs && serverResponse.uuids) { + serverResponse.uuids.forEach(function (uuidEntry) { + if (includeState) { + occupantsList.push({ state: uuidEntry.state, uuid: uuidEntry.uuid }); + } + else { + occupantsList.push({ state: null, uuid: uuidEntry }); + } + }); + } + return response; + }; + var prepareMultipleChannel = function () { + var response = {}; + response.totalChannels = serverResponse.payload.total_channels; + response.totalOccupancy = serverResponse.payload.total_occupancy; + response.channels = {}; + Object.keys(serverResponse.payload.channels).forEach(function (channelName) { + var channelEntry = serverResponse.payload.channels[channelName]; + var occupantsList = []; + response.channels[channelName] = { + occupants: occupantsList, + name: channelName, + occupancy: channelEntry.occupancy, + }; + if (includeUUIDs) { + channelEntry.uuids.forEach(function (uuidEntry) { + if (includeState) { + occupantsList.push({ + state: uuidEntry.state, + uuid: uuidEntry.uuid, + }); + } + else { + occupantsList.push({ state: null, uuid: uuidEntry }); + } + }); + } + return response; + }); + return response; + }; + var response; + if (channels.length > 1 || channelGroups.length > 0 || (channelGroups.length === 0 && channels.length === 0)) { + response = prepareMultipleChannel(); + } + else { + response = prepareSingularChannel(); + } + return response; + } + function handleError(modules, params, status) { + if (status.statusCode === 402 && !this.getURL(modules, params).includes('channel')) { + status.errorData.message = + 'You have tried to perform a Global Here Now operation, ' + + 'your keyset configuration does not support that. Please provide a channel, ' + + 'or enable the Global Here Now feature from the Portal.'; + } + } + + var presenceHereNowConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$e, + validateParams: validateParams$e, + getURL: getURL$c, + getRequestTimeout: getRequestTimeout$e, + isAuthSupported: isAuthSupported$e, + prepareParams: prepareParams$e, + handleResponse: handleResponse$e, + handleError: handleError + }); + + /* */ + function getOperation$d() { + return OPERATIONS.PNAddMessageActionOperation; + } + function validateParams$d(_a, incomingParams) { + var config = _a.config; + var action = incomingParams.action, channel = incomingParams.channel, messageTimetoken = incomingParams.messageTimetoken; + if (!messageTimetoken) + return 'Missing message timetoken'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + if (!channel) + return 'Missing message channel'; + if (!action) + return 'Missing Action'; + if (!action.value) + return 'Missing Action.value'; + if (!action.type) + return 'Missing Action.type'; + if (action.type.length > 15) + return 'Action.type value exceed maximum length of 15'; + } + function usePost$2() { + return true; + } + function postURL$2(_a, incomingParams) { + var config = _a.config; + var channel = incomingParams.channel, messageTimetoken = incomingParams.messageTimetoken; + return "/v1/message-actions/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel), "/message/").concat(messageTimetoken); + } + function getRequestTimeout$d(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function getRequestHeaders() { + return { 'Content-Type': 'application/json' }; + } + function isAuthSupported$d() { + return true; + } + function prepareParams$d() { + return {}; + } + function postPayload$2(modules, incomingParams) { + return incomingParams.action; + } + function handleResponse$d(modules, addMessageActionResponse) { + return { data: addMessageActionResponse.data }; + } + + var addMessageActionEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$d, + validateParams: validateParams$d, + usePost: usePost$2, + postURL: postURL$2, + getRequestTimeout: getRequestTimeout$d, + getRequestHeaders: getRequestHeaders, + isAuthSupported: isAuthSupported$d, + prepareParams: prepareParams$d, + postPayload: postPayload$2, + handleResponse: handleResponse$d + }); + + /* */ + function getOperation$c() { + return OPERATIONS.PNRemoveMessageActionOperation; + } + function validateParams$c(_a, incomingParams) { + var config = _a.config; + var channel = incomingParams.channel, actionTimetoken = incomingParams.actionTimetoken, messageTimetoken = incomingParams.messageTimetoken; + if (!messageTimetoken) + return 'Missing message timetoken'; + if (!actionTimetoken) + return 'Missing action timetoken'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + if (!channel) + return 'Missing message channel'; + } + function useDelete$1() { + return true; + } + function getURL$b(_a, incomingParams) { + var config = _a.config; + var channel = incomingParams.channel, actionTimetoken = incomingParams.actionTimetoken, messageTimetoken = incomingParams.messageTimetoken; + return "/v1/message-actions/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel), "/message/").concat(messageTimetoken, "/action/").concat(actionTimetoken); + } + function getRequestTimeout$c(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$c() { + return true; + } + function prepareParams$c() { + return {}; + } + function handleResponse$c(modules, removeMessageActionResponse) { + return { data: removeMessageActionResponse.data }; + } + + var removeMessageActionEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$c, + validateParams: validateParams$c, + useDelete: useDelete$1, + getURL: getURL$b, + getRequestTimeout: getRequestTimeout$c, + isAuthSupported: isAuthSupported$c, + prepareParams: prepareParams$c, + handleResponse: handleResponse$c + }); + + /* */ + function getOperation$b() { + return OPERATIONS.PNGetMessageActionsOperation; + } + function validateParams$b(_a, incomingParams) { + var config = _a.config; + var channel = incomingParams.channel; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + if (!channel) + return 'Missing message channel'; + } + function getURL$a(_a, incomingParams) { + var config = _a.config; + var channel = incomingParams.channel; + return "/v1/message-actions/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel)); + } + function getRequestTimeout$b(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$b() { + return true; + } + function prepareParams$b(modules, incomingParams) { + var limit = incomingParams.limit, start = incomingParams.start, end = incomingParams.end; + var outgoingParams = {}; + if (limit) + outgoingParams.limit = limit; + if (start) + outgoingParams.start = start; + if (end) + outgoingParams.end = end; + return outgoingParams; + } + function handleResponse$b(modules, getMessageActionsResponse) { + /** @type GetMessageActionsResponse */ + var response = { data: getMessageActionsResponse.data, start: null, end: null }; + if (response.data.length) { + response.end = response.data[response.data.length - 1].actionTimetoken; + response.start = response.data[0].actionTimetoken; + } + return response; + } + + var getMessageActionEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$b, + validateParams: validateParams$b, + getURL: getURL$a, + getRequestTimeout: getRequestTimeout$b, + isAuthSupported: isAuthSupported$b, + prepareParams: prepareParams$b, + handleResponse: handleResponse$b + }); + + /** */ + var endpoint$j = { + getOperation: function () { return OPERATIONS.PNListFilesOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return "channel can't be empty"; + } + }, + getURL: function (_a, params) { + var config = _a.config; + return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/files"); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_, params) { + var outParams = {}; + if (params.limit) { + outParams.limit = params.limit; + } + if (params.next) { + outParams.next = params.next; + } + return outParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + next: response.next, + count: response.count, + }); }, + }; + + /** */ + var endpoint$i = { + getOperation: function () { return OPERATIONS.PNGenerateUploadUrlOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return "channel can't be empty"; + } + if (!(params === null || params === void 0 ? void 0 : params.name)) { + return "name can't be empty"; + } + }, + usePost: function () { return true; }, + postURL: function (_a, params) { + var config = _a.config; + return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/generate-upload-url"); + }, + postPayload: function (_, params) { return ({ + name: params.name, + }); }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function () { return ({}); }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + file_upload_request: response.file_upload_request, + }); }, + }; + + /** */ + var preparePayload = function (_a, payload) { + var crypto = _a.crypto, config = _a.config; + var stringifiedPayload = JSON.stringify(payload); + if (config.cipherKey) { + stringifiedPayload = crypto.encrypt(stringifiedPayload); + stringifiedPayload = JSON.stringify(stringifiedPayload); + } + return stringifiedPayload || ''; + }; + var endpoint$h = { + getOperation: function () { return OPERATIONS.PNPublishFileOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return "channel can't be empty"; + } + if (!(params === null || params === void 0 ? void 0 : params.fileId)) { + return "file id can't be empty"; + } + if (!(params === null || params === void 0 ? void 0 : params.fileName)) { + return "file name can't be empty"; + } + }, + getURL: function (modules, params) { + var _a = modules.config, publishKey = _a.publishKey, subscribeKey = _a.subscribeKey; + var message = { + message: params.message, + file: { + name: params.fileName, + id: params.fileId, + }, + }; + var payload = preparePayload(modules, message); + return "/v1/files/publish-file/".concat(publishKey, "/").concat(subscribeKey, "/0/").concat(utils$5.encodeString(params.channel), "/0/").concat(utils$5.encodeString(payload)); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_, params) { + var outParams = {}; + if (params.ttl) { + outParams.ttl = params.ttl; + } + if (params.storeInHistory !== undefined) { + outParams.store = params.storeInHistory ? '1' : '0'; + } + if (params.meta && typeof params.meta === 'object') { + outParams.meta = JSON.stringify(params.meta); + } + return outParams; + }, + handleResponse: function (_, response) { return ({ + timetoken: response['2'], + }); }, + }; + + var getErrorFromResponse = function (response) { + return new Promise(function (resolve) { + var result = ''; + response.on('data', function (data) { + result += data.toString('utf8'); + }); + response.on('end', function () { + resolve(result); + }); + }); + }; + var sendFile = function (_a) { + var _this = this; + var generateUploadUrl = _a.generateUploadUrl, publishFile = _a.publishFile, _b = _a.modules, PubNubFile = _b.PubNubFile, config = _b.config, cryptography = _b.cryptography, networking = _b.networking; + return function (_a) { + var channel = _a.channel, input = _a.file, message = _a.message, cipherKey = _a.cipherKey, meta = _a.meta, ttl = _a.ttl, storeInHistory = _a.storeInHistory; + return __awaiter(_this, void 0, void 0, function () { + var file, _b, _c, url, formFields, _d, id, name, formFieldsWithMimeType, result, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, e_1, errorBody, reason, retries, wasSuccessful, publishResult; + return __generator(this, function (_s) { + switch (_s.label) { + case 0: + if (!channel) { + throw new PubNubError('Validation failed, check status for details', createValidationError("channel can't be empty")); + } + if (!input) { + throw new PubNubError('Validation failed, check status for details', createValidationError("file can't be empty")); + } + file = PubNubFile.create(input); + return [4 /*yield*/, generateUploadUrl({ channel: channel, name: file.name })]; + case 1: + _b = _s.sent(), _c = _b.file_upload_request, url = _c.url, formFields = _c.form_fields, _d = _b.data, id = _d.id, name = _d.name; + if (!(PubNubFile.supportsEncryptFile && (cipherKey !== null && cipherKey !== void 0 ? cipherKey : config.cipherKey))) return [3 /*break*/, 3]; + return [4 /*yield*/, cryptography.encryptFile(cipherKey !== null && cipherKey !== void 0 ? cipherKey : config.cipherKey, file, PubNubFile)]; + case 2: + file = _s.sent(); + _s.label = 3; + case 3: + formFieldsWithMimeType = formFields; + if (file.mimeType) { + formFieldsWithMimeType = formFields.map(function (entry) { + if (entry.key === 'Content-Type') + return { key: entry.key, value: file.mimeType }; + return entry; + }); + } + _s.label = 4; + case 4: + _s.trys.push([4, 18, , 22]); + if (!(PubNubFile.supportsFileUri && input.uri)) return [3 /*break*/, 7]; + _f = (_e = networking).POSTFILE; + _g = [url, formFieldsWithMimeType]; + return [4 /*yield*/, file.toFileUri()]; + case 5: return [4 /*yield*/, _f.apply(_e, _g.concat([_s.sent()]))]; + case 6: + result = _s.sent(); + return [3 /*break*/, 17]; + case 7: + if (!PubNubFile.supportsFile) return [3 /*break*/, 10]; + _j = (_h = networking).POSTFILE; + _k = [url, formFieldsWithMimeType]; + return [4 /*yield*/, file.toFile()]; + case 8: return [4 /*yield*/, _j.apply(_h, _k.concat([_s.sent()]))]; + case 9: + result = _s.sent(); + return [3 /*break*/, 17]; + case 10: + if (!PubNubFile.supportsBuffer) return [3 /*break*/, 13]; + _m = (_l = networking).POSTFILE; + _o = [url, formFieldsWithMimeType]; + return [4 /*yield*/, file.toBuffer()]; + case 11: return [4 /*yield*/, _m.apply(_l, _o.concat([_s.sent()]))]; + case 12: + result = _s.sent(); + return [3 /*break*/, 17]; + case 13: + if (!PubNubFile.supportsBlob) return [3 /*break*/, 16]; + _q = (_p = networking).POSTFILE; + _r = [url, formFieldsWithMimeType]; + return [4 /*yield*/, file.toBlob()]; + case 14: return [4 /*yield*/, _q.apply(_p, _r.concat([_s.sent()]))]; + case 15: + result = _s.sent(); + return [3 /*break*/, 17]; + case 16: throw new Error('Unsupported environment'); + case 17: return [3 /*break*/, 22]; + case 18: + e_1 = _s.sent(); + if (!e_1.response) return [3 /*break*/, 20]; + return [4 /*yield*/, getErrorFromResponse(e_1.response)]; + case 19: + errorBody = _s.sent(); + reason = /(.*)<\/Message>/gi.exec(errorBody); + throw new PubNubError(reason ? "Upload to bucket failed: ".concat(reason[1]) : 'Upload to bucket failed.', e_1); + case 20: throw new PubNubError('Upload to bucket failed.', e_1); + case 21: return [3 /*break*/, 22]; + case 22: + if (result.status !== 204) { + throw new PubNubError('Upload to bucket was unsuccessful', result); + } + retries = config.fileUploadPublishRetryLimit; + wasSuccessful = false; + publishResult = { timetoken: '0' }; + _s.label = 23; + case 23: + _s.trys.push([23, 25, , 26]); + return [4 /*yield*/, publishFile({ + channel: channel, + message: message, + fileId: id, + fileName: name, + meta: meta, + storeInHistory: storeInHistory, + ttl: ttl, + })]; + case 24: + /* eslint-disable-next-line no-await-in-loop */ + publishResult = _s.sent(); + wasSuccessful = true; + return [3 /*break*/, 26]; + case 25: + _s.sent(); + retries -= 1; + return [3 /*break*/, 26]; + case 26: + if (!wasSuccessful && retries > 0) return [3 /*break*/, 23]; + _s.label = 27; + case 27: + if (!wasSuccessful) { + throw new PubNubError('Publish failed. You may want to execute that operation manually using pubnub.publishFile', { + channel: channel, + id: id, + name: name, + }); + } + else { + return [2 /*return*/, { + timetoken: publishResult.timetoken, + id: id, + name: name, + }]; + } + } + }); + }); + }; + }; + var sendFileFunction = (function (deps) { + var f = sendFile(deps); + return function (params, cb) { + var resultP = f(params); + if (typeof cb === 'function') { + resultP.then(function (result) { return cb(null, result); }).catch(function (error) { return cb(error, null); }); + return resultP; + } + return resultP; + }; + }); + + /** */ + var getFileUrlFunction = (function (modules, _a) { + var channel = _a.channel, id = _a.id, name = _a.name; + var config = modules.config, networking = modules.networking, tokenManager = modules.tokenManager; + if (!channel) { + throw new PubNubError('Validation failed, check status for details', createValidationError("channel can't be empty")); + } + if (!id) { + throw new PubNubError('Validation failed, check status for details', createValidationError("file id can't be empty")); + } + if (!name) { + throw new PubNubError('Validation failed, check status for details', createValidationError("file name can't be empty")); + } + var url = "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(channel), "/files/").concat(id, "/").concat(name); + var params = {}; + params.uuid = config.getUUID(); + params.pnsdk = generatePNSDK(config); + var tokenOrKey = tokenManager.getToken() || config.getAuthKey(); + if (tokenOrKey) { + params.auth = tokenOrKey; + } + if (config.secretKey) { + signRequest(modules, url, params, {}, { + getOperation: function () { return 'PubNubGetFileUrlOperation'; }, + }); + } + var queryParams = Object.keys(params) + .map(function (key) { return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(params[key])); }) + .join('&'); + if (queryParams !== '') { + return "".concat(networking.getStandardOrigin()).concat(url, "?").concat(queryParams); + } + return "".concat(networking.getStandardOrigin()).concat(url); + }); + + /** */ + var endpoint$g = { + getOperation: function () { return OPERATIONS.PNDownloadFileOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return "channel can't be empty"; + } + if (!(params === null || params === void 0 ? void 0 : params.name)) { + return "name can't be empty"; + } + if (!(params === null || params === void 0 ? void 0 : params.id)) { + return "id can't be empty"; + } + }, + useGetFile: function () { return true; }, + getFileURL: function (_a, params) { + var config = _a.config; + return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/files/").concat(params.id, "/").concat(params.name); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + ignoreBody: function () { return true; }, + forceBuffered: function () { return true; }, + prepareParams: function () { return ({}); }, + handleResponse: function (_a, res, params) { + var PubNubFile = _a.PubNubFile, config = _a.config, cryptography = _a.cryptography; + return __awaiter(void 0, void 0, void 0, function () { + var body; + var _b, _c, _d; + return __generator(this, function (_e) { + switch (_e.label) { + case 0: + body = res.response.body; + if (!(PubNubFile.supportsEncryptFile && ((_b = params.cipherKey) !== null && _b !== void 0 ? _b : config.cipherKey))) return [3 /*break*/, 2]; + return [4 /*yield*/, cryptography.decrypt((_c = params.cipherKey) !== null && _c !== void 0 ? _c : config.cipherKey, body)]; + case 1: + body = _e.sent(); + _e.label = 2; + case 2: return [2 /*return*/, PubNubFile.create({ + data: body, + name: (_d = res.response.name) !== null && _d !== void 0 ? _d : params.name, + mimeType: res.response.type, + })]; + } + }); + }); + }, + }; + + /** */ + var endpoint$f = { + getOperation: function () { return OPERATIONS.PNListFilesOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return "channel can't be empty"; + } + if (!(params === null || params === void 0 ? void 0 : params.id)) { + return "file id can't be empty"; + } + if (!(params === null || params === void 0 ? void 0 : params.name)) { + return "file name can't be empty"; + } + }, + useDelete: function () { return true; }, + getURL: function (_a, params) { + var config = _a.config; + return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/files/").concat(params.id, "/").concat(params.name); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function () { return ({}); }, + handleResponse: function (_, response) { return ({ + status: response.status, + }); }, + }; + + var endpoint$e = { + getOperation: function () { return OPERATIONS.PNGetAllUUIDMetadataOperation; }, + validateParams: function () { + // No required parameters. + }, + getURL: function (_a) { + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/uuids"); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_modules, params) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + var queryParams = {}; + queryParams.include = ['status', 'type']; + if (params === null || params === void 0 ? void 0 : params.include) { + if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { + queryParams.include.push('custom'); + } + } + queryParams.include = queryParams.include.join(','); + if ((_b = params === null || params === void 0 ? void 0 : params.include) === null || _b === void 0 ? void 0 : _b.totalCount) { + queryParams.count = (_c = params.include) === null || _c === void 0 ? void 0 : _c.totalCount; + } + if ((_d = params === null || params === void 0 ? void 0 : params.page) === null || _d === void 0 ? void 0 : _d.next) { + queryParams.start = (_e = params.page) === null || _e === void 0 ? void 0 : _e.next; + } + if ((_f = params === null || params === void 0 ? void 0 : params.page) === null || _f === void 0 ? void 0 : _f.prev) { + queryParams.end = (_g = params.page) === null || _g === void 0 ? void 0 : _g.prev; + } + if (params === null || params === void 0 ? void 0 : params.filter) { + queryParams.filter = params.filter; + } + queryParams.limit = (_h = params === null || params === void 0 ? void 0 : params.limit) !== null && _h !== void 0 ? _h : 100; + if (params === null || params === void 0 ? void 0 : params.sort) { + queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + if (value === 'asc' || value === 'desc') { + return "".concat(key, ":").concat(value); + } + return key; + }); + } + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + totalCount: response.totalCount, + next: response.next, + prev: response.prev, + }); }, + }; + + /** */ + var endpoint$d = { + getOperation: function () { return OPERATIONS.PNGetUUIDMetadataOperation; }, + validateParams: function () { + // No required parameters. + }, + getURL: function (_a, params) { + var _b; + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID())); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_a, params) { + var _b, _c; + var config = _a.config; + var queryParams = {}; + queryParams.uuid = (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID(); + queryParams.include = ['status', 'type', 'custom']; + if (params === null || params === void 0 ? void 0 : params.include) { + if (((_c = params.include) === null || _c === void 0 ? void 0 : _c.customFields) === false) { + queryParams.include.pop(); + } + } + queryParams.include = queryParams.include.join(','); + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, + }; + + /** */ + var endpoint$c = { + getOperation: function () { return OPERATIONS.PNSetUUIDMetadataOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.data)) { + return 'Data cannot be empty'; + } + }, + usePatch: function () { return true; }, + patchURL: function (_a, params) { + var _b; + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params.uuid) !== null && _b !== void 0 ? _b : config.getUUID())); + }, + patchPayload: function (_, params) { return params.data; }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_a, params) { + var _b, _c; + var config = _a.config; + var queryParams = {}; + queryParams.uuid = (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID(); + queryParams.include = ['status', 'type', 'custom']; + if (params === null || params === void 0 ? void 0 : params.include) { + if (((_c = params.include) === null || _c === void 0 ? void 0 : _c.customFields) === false) { + queryParams.include.pop(); + } + } + queryParams.include = queryParams.include.join(','); + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, + }; + + /** */ + var endpoint$b = { + getOperation: function () { return OPERATIONS.PNRemoveUUIDMetadataOperation; }, + validateParams: function () { + // No required parameters. + }, + getURL: function (_a, params) { + var _b; + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID())); + }, + useDelete: function () { return true; }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_a, params) { + var _b; + var config = _a.config; + return ({ + uuid: (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID(), + }); + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, + }; + + var endpoint$a = { + getOperation: function () { return OPERATIONS.PNGetAllChannelMetadataOperation; }, + validateParams: function () { + // No required parameters. + }, + getURL: function (_a) { + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/channels"); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_modules, params) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + var queryParams = {}; + queryParams.include = ['status', 'type']; + if (params === null || params === void 0 ? void 0 : params.include) { + if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { + queryParams.include.push('custom'); + } + } + queryParams.include = queryParams.include.join(','); + if ((_b = params === null || params === void 0 ? void 0 : params.include) === null || _b === void 0 ? void 0 : _b.totalCount) { + queryParams.count = (_c = params.include) === null || _c === void 0 ? void 0 : _c.totalCount; + } + if ((_d = params === null || params === void 0 ? void 0 : params.page) === null || _d === void 0 ? void 0 : _d.next) { + queryParams.start = (_e = params.page) === null || _e === void 0 ? void 0 : _e.next; + } + if ((_f = params === null || params === void 0 ? void 0 : params.page) === null || _f === void 0 ? void 0 : _f.prev) { + queryParams.end = (_g = params.page) === null || _g === void 0 ? void 0 : _g.prev; + } + if (params === null || params === void 0 ? void 0 : params.filter) { + queryParams.filter = params.filter; + } + queryParams.limit = (_h = params === null || params === void 0 ? void 0 : params.limit) !== null && _h !== void 0 ? _h : 100; + if (params === null || params === void 0 ? void 0 : params.sort) { + queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + if (value === 'asc' || value === 'desc') { + return "".concat(key, ":").concat(value); + } + return key; + }); + } + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + totalCount: response.totalCount, + prev: response.prev, + next: response.next, + }); }, + }; + + var endpoint$9 = { + getOperation: function () { return OPERATIONS.PNGetChannelMetadataOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return 'Channel cannot be empty'; + } + }, + getURL: function (_a, params) { + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel)); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_, params) { + var _a; + var queryParams = {}; + queryParams.include = ['status', 'type', 'custom']; + if (params === null || params === void 0 ? void 0 : params.include) { + if (((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) === false) { + queryParams.include.pop(); + } + } + queryParams.include = queryParams.include.join(','); + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, + }; + + /** */ + var endpoint$8 = { + getOperation: function () { return OPERATIONS.PNSetChannelMetadataOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return 'Channel cannot be empty'; + } + if (!(params === null || params === void 0 ? void 0 : params.data)) { + return 'Data cannot be empty'; + } + }, + usePatch: function () { return true; }, + patchURL: function (_a, params) { + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel)); + }, + patchPayload: function (_, params) { return params.data; }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_, params) { + var _a; + var queryParams = {}; + queryParams.include = ['status', 'type', 'custom']; + if (params === null || params === void 0 ? void 0 : params.include) { + if (((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) === false) { + queryParams.include.pop(); + } + } + queryParams.include = queryParams.include.join(','); + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, + }; + + /** */ + var endpoint$7 = { + getOperation: function () { return OPERATIONS.PNRemoveChannelMetadataOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return 'Channel cannot be empty'; + } + }, + getURL: function (_a, params) { + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel)); + }, + useDelete: function () { return true; }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function () { return ({}); }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, + }; + + /** */ + var endpoint$6 = { + getOperation: function () { return OPERATIONS.PNGetMembersOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return 'UUID cannot be empty'; + } + }, + getURL: function (_a, params) { + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/uuids"); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_modules, params) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; + var queryParams = {}; + queryParams.include = ['uuid.status', 'uuid.type', 'type']; + if (params === null || params === void 0 ? void 0 : params.include) { + if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { + queryParams.include.push('custom'); + } + if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customUUIDFields) { + queryParams.include.push('uuid.custom'); + } + if ((_d = (_c = params.include) === null || _c === void 0 ? void 0 : _c.UUIDFields) !== null && _d !== void 0 ? _d : true) { + queryParams.include.push('uuid'); + } + } + queryParams.include = queryParams.include.join(','); + if ((_e = params === null || params === void 0 ? void 0 : params.include) === null || _e === void 0 ? void 0 : _e.totalCount) { + queryParams.count = (_f = params.include) === null || _f === void 0 ? void 0 : _f.totalCount; + } + if ((_g = params === null || params === void 0 ? void 0 : params.page) === null || _g === void 0 ? void 0 : _g.next) { + queryParams.start = (_h = params.page) === null || _h === void 0 ? void 0 : _h.next; + } + if ((_j = params === null || params === void 0 ? void 0 : params.page) === null || _j === void 0 ? void 0 : _j.prev) { + queryParams.end = (_k = params.page) === null || _k === void 0 ? void 0 : _k.prev; + } + if (params === null || params === void 0 ? void 0 : params.filter) { + queryParams.filter = params.filter; + } + queryParams.limit = (_l = params === null || params === void 0 ? void 0 : params.limit) !== null && _l !== void 0 ? _l : 100; + if (params === null || params === void 0 ? void 0 : params.sort) { + queryParams.sort = Object.entries((_m = params.sort) !== null && _m !== void 0 ? _m : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + if (value === 'asc' || value === 'desc') { + return "".concat(key, ":").concat(value); + } + return key; + }); + } + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + totalCount: response.totalCount, + prev: response.prev, + next: response.next, + }); }, + }; + + var endpoint$5 = { + getOperation: function () { return OPERATIONS.PNSetMembersOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channel)) { + return 'Channel cannot be empty'; + } + if (!(params === null || params === void 0 ? void 0 : params.uuids) || (params === null || params === void 0 ? void 0 : params.uuids.length) === 0) { + return 'UUIDs cannot be empty'; + } + }, + usePatch: function () { return true; }, + patchURL: function (_a, params) { + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/uuids"); + }, + patchPayload: function (_, params) { + var _a; + return (_a = { + set: [], + delete: [] + }, + _a[params.type] = params.uuids.map(function (uuid) { + if (typeof uuid === 'string') { + return { + uuid: { + id: uuid, + }, + }; + } + return { + uuid: { id: uuid.id }, + custom: uuid.custom, + status: uuid.status, + }; + }), + _a); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_modules, params) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + var queryParams = {}; + queryParams.include = ['uuid.status', 'uuid.type', 'type']; + if (params === null || params === void 0 ? void 0 : params.include) { + if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { + queryParams.include.push('custom'); + } + if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customUUIDFields) { + queryParams.include.push('uuid.custom'); + } + if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.UUIDFields) { + queryParams.include.push('uuid'); + } + } + queryParams.include = queryParams.include.join(','); + if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) { + queryParams.count = true; + } + if ((_e = params === null || params === void 0 ? void 0 : params.page) === null || _e === void 0 ? void 0 : _e.next) { + queryParams.start = (_f = params.page) === null || _f === void 0 ? void 0 : _f.next; + } + if ((_g = params === null || params === void 0 ? void 0 : params.page) === null || _g === void 0 ? void 0 : _g.prev) { + queryParams.end = (_h = params.page) === null || _h === void 0 ? void 0 : _h.prev; + } + if (params === null || params === void 0 ? void 0 : params.filter) { + queryParams.filter = params.filter; + } + if (params.limit != null) { + queryParams.limit = params.limit; + } + if (params === null || params === void 0 ? void 0 : params.sort) { + queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + if (value === 'asc' || value === 'desc') { + return "".concat(key, ":").concat(value); + } + return key; + }); + } + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + totalCount: response.totalCount, + prev: response.prev, + next: response.next, + }); }, + }; + + var endpoint$4 = { + getOperation: function () { return OPERATIONS.PNGetMembershipsOperation; }, + validateParams: function () { + // No required parameters. + }, + getURL: function (_a, params) { + var _b; + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID()), "/channels"); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_modules, params) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; + var queryParams = {}; + queryParams.include = ['channel.status', 'channel.type', 'status']; + if (params === null || params === void 0 ? void 0 : params.include) { + if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { + queryParams.include.push('custom'); + } + if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customChannelFields) { + queryParams.include.push('channel.custom'); + } + if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.channelFields) { + queryParams.include.push('channel'); + } + } + queryParams.include = queryParams.include.join(','); + if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) { + queryParams.count = (_e = params.include) === null || _e === void 0 ? void 0 : _e.totalCount; + } + if ((_f = params === null || params === void 0 ? void 0 : params.page) === null || _f === void 0 ? void 0 : _f.next) { + queryParams.start = (_g = params.page) === null || _g === void 0 ? void 0 : _g.next; + } + if ((_h = params === null || params === void 0 ? void 0 : params.page) === null || _h === void 0 ? void 0 : _h.prev) { + queryParams.end = (_j = params.page) === null || _j === void 0 ? void 0 : _j.prev; + } + if (params === null || params === void 0 ? void 0 : params.filter) { + queryParams.filter = params.filter; + } + queryParams.limit = (_k = params === null || params === void 0 ? void 0 : params.limit) !== null && _k !== void 0 ? _k : 100; + if (params === null || params === void 0 ? void 0 : params.sort) { + queryParams.sort = Object.entries((_l = params.sort) !== null && _l !== void 0 ? _l : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + if (value === 'asc' || value === 'desc') { + return "".concat(key, ":").concat(value); + } + return key; + }); + } + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + totalCount: response.totalCount, + prev: response.prev, + next: response.next, + }); }, + }; + + /** */ + var endpoint$3 = { + getOperation: function () { return OPERATIONS.PNSetMembershipsOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channels) || (params === null || params === void 0 ? void 0 : params.channels.length) === 0) { + return 'Channels cannot be empty'; + } + }, + usePatch: function () { return true; }, + patchURL: function (_a, params) { + var _b; + var config = _a.config; + return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params.uuid) !== null && _b !== void 0 ? _b : config.getUUID()), "/channels"); + }, + patchPayload: function (_, params) { + var _a; + return (_a = { + set: [], + delete: [] + }, + _a[params.type] = params.channels.map(function (channel) { + if (typeof channel === 'string') { + return { + channel: { + id: channel, + }, + }; + } + return { + channel: { id: channel.id }, + custom: channel.custom, + status: channel.status, + }; + }), + _a); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_modules, params) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j; + var queryParams = {}; + queryParams.include = ['channel.status', 'channel.type', 'status']; + if (params === null || params === void 0 ? void 0 : params.include) { + if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { + queryParams.include.push('custom'); + } + if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customChannelFields) { + queryParams.include.push('channel.custom'); + } + if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.channelFields) { + queryParams.include.push('channel'); + } + } + queryParams.include = queryParams.include.join(','); + if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) { + queryParams.count = true; + } + if ((_e = params === null || params === void 0 ? void 0 : params.page) === null || _e === void 0 ? void 0 : _e.next) { + queryParams.start = (_f = params.page) === null || _f === void 0 ? void 0 : _f.next; + } + if ((_g = params === null || params === void 0 ? void 0 : params.page) === null || _g === void 0 ? void 0 : _g.prev) { + queryParams.end = (_h = params.page) === null || _h === void 0 ? void 0 : _h.prev; + } + if (params === null || params === void 0 ? void 0 : params.filter) { + queryParams.filter = params.filter; + } + if (params.limit != null) { + queryParams.limit = params.limit; + } + if (params === null || params === void 0 ? void 0 : params.sort) { + queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { + var _b = __read(_a, 2), key = _b[0], value = _b[1]; + if (value === 'asc' || value === 'desc') { + return "".concat(key, ":").concat(value); + } + return key; + }); + } + return queryParams; + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + totalCount: response.totalCount, + prev: response.prev, + next: response.next, + }); }, + }; + + /* */ + function getOperation$a() { + return OPERATIONS.PNAccessManagerAudit; + } + function validateParams$a(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$9(modules) { + var config = modules.config; + return "/v2/auth/audit/sub-key/".concat(config.subscribeKey); + } + function getRequestTimeout$a(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$a() { + return false; + } + function prepareParams$a(modules, incomingParams) { + var channel = incomingParams.channel, channelGroup = incomingParams.channelGroup, _a = incomingParams.authKeys, authKeys = _a === void 0 ? [] : _a; + var params = {}; + if (channel) { + params.channel = channel; + } + if (channelGroup) { + params['channel-group'] = channelGroup; + } + if (authKeys.length > 0) { + params.auth = authKeys.join(','); + } + return params; + } + function handleResponse$a(modules, serverResponse) { + return serverResponse.payload; + } + + var auditEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$a, + validateParams: validateParams$a, + getURL: getURL$9, + getRequestTimeout: getRequestTimeout$a, + isAuthSupported: isAuthSupported$a, + prepareParams: prepareParams$a, + handleResponse: handleResponse$a + }); + + /* */ + function getOperation$9() { + return OPERATIONS.PNAccessManagerGrant; + } + function validateParams$9(modules, incomingParams) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + if (!config.publishKey) + return 'Missing Publish Key'; + if (!config.secretKey) + return 'Missing Secret Key'; + if (incomingParams.uuids != null && !incomingParams.authKeys) { + return 'authKeys are required for grant request on uuids'; + } + if (incomingParams.uuids != null && (incomingParams.channels != null || incomingParams.channelGroups != null)) { + return 'Both channel/channelgroup and uuid cannot be used in the same request'; + } + } + function getURL$8(modules) { + var config = modules.config; + return "/v2/auth/grant/sub-key/".concat(config.subscribeKey); + } + function getRequestTimeout$9(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$9() { + return false; + } + function prepareParams$9(modules, incomingParams) { + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = incomingParams.uuids, uuids = _c === void 0 ? [] : _c, ttl = incomingParams.ttl, _d = incomingParams.read, read = _d === void 0 ? false : _d, _e = incomingParams.write, write = _e === void 0 ? false : _e, _f = incomingParams.manage, manage = _f === void 0 ? false : _f, _g = incomingParams.get, get = _g === void 0 ? false : _g, _h = incomingParams.join, join = _h === void 0 ? false : _h, _j = incomingParams.update, update = _j === void 0 ? false : _j, _k = incomingParams.authKeys, authKeys = _k === void 0 ? [] : _k; + var deleteParam = incomingParams.delete; + var params = {}; + params.r = read ? '1' : '0'; + params.w = write ? '1' : '0'; + params.m = manage ? '1' : '0'; + params.d = deleteParam ? '1' : '0'; + params.g = get ? '1' : '0'; + params.j = join ? '1' : '0'; + params.u = update ? '1' : '0'; + if (channels.length > 0) { + params.channel = channels.join(','); + } + if (channelGroups.length > 0) { + params['channel-group'] = channelGroups.join(','); + } + if (authKeys.length > 0) { + params.auth = authKeys.join(','); + } + if (uuids.length > 0) { + params['target-uuid'] = uuids.join(','); + } + if (ttl || ttl === 0) { + params.ttl = ttl; + } + return params; + } + function handleResponse$9() { + return {}; + } + + var grantEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$9, + validateParams: validateParams$9, + getURL: getURL$8, + getRequestTimeout: getRequestTimeout$9, + isAuthSupported: isAuthSupported$9, + prepareParams: prepareParams$9, + handleResponse: handleResponse$9 + }); + + function getOperation$8() { + return OPERATIONS.PNAccessManagerGrantToken; + } + function hasVspTerms(incomingParams) { + var _a, _b, _c, _d; + var hasAuthorizedUserId = (incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.authorizedUserId) !== undefined; + var hasUserResources = ((_a = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _a === void 0 ? void 0 : _a.users) !== undefined; + var hasSpaceResources = ((_b = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _b === void 0 ? void 0 : _b.spaces) !== undefined; + var hasUserPatterns = ((_c = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _c === void 0 ? void 0 : _c.users) !== undefined; + var hasSpacePatterns = ((_d = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _d === void 0 ? void 0 : _d.spaces) !== undefined; + return hasUserPatterns || hasUserResources || hasSpacePatterns || hasSpaceResources || hasAuthorizedUserId; + } + function extractPermissions(permissions) { + var permissionsResult = 0; + if (permissions.join) { + permissionsResult |= 128; + } + if (permissions.update) { + permissionsResult |= 64; + } + if (permissions.get) { + permissionsResult |= 32; + } + if (permissions.delete) { + permissionsResult |= 8; + } + if (permissions.manage) { + permissionsResult |= 4; + } + if (permissions.write) { + permissionsResult |= 2; + } + if (permissions.read) { + permissionsResult |= 1; + } + return permissionsResult; + } + function prepareMessagePayloadVsp(_modules, _a) { + var ttl = _a.ttl, resources = _a.resources, patterns = _a.patterns, meta = _a.meta, authorizedUserId = _a.authorizedUserId; + var params = { + ttl: 0, + permissions: { + resources: { + channels: {}, + groups: {}, + uuids: {}, + users: {}, + spaces: {}, // not used, needed for api backward compatibility + }, + patterns: { + channels: {}, + groups: {}, + uuids: {}, + users: {}, + spaces: {}, // not used, needed for api backward compatibility + }, + meta: {}, + }, + }; + if (resources) { + var users_1 = resources.users, spaces_1 = resources.spaces, groups_1 = resources.groups; + if (users_1) { + Object.keys(users_1).forEach(function (userID) { + params.permissions.resources.uuids[userID] = extractPermissions(users_1[userID]); + }); + } + if (spaces_1) { + Object.keys(spaces_1).forEach(function (spaceId) { + params.permissions.resources.channels[spaceId] = extractPermissions(spaces_1[spaceId]); + }); + } + if (groups_1) { + Object.keys(groups_1).forEach(function (group) { + params.permissions.resources.groups[group] = extractPermissions(groups_1[group]); + }); + } + } + if (patterns) { + var users_2 = patterns.users, spaces_2 = patterns.spaces, groups_2 = patterns.groups; + if (users_2) { + Object.keys(users_2).forEach(function (userId) { + params.permissions.patterns.uuids[userId] = extractPermissions(users_2[userId]); + }); + } + if (spaces_2) { + Object.keys(spaces_2).forEach(function (spaceId) { + params.permissions.patterns.channels[spaceId] = extractPermissions(spaces_2[spaceId]); + }); + } + if (groups_2) { + Object.keys(groups_2).forEach(function (group) { + params.permissions.patterns.groups[group] = extractPermissions(groups_2[group]); + }); + } + } + if (ttl || ttl === 0) { + params.ttl = ttl; + } + if (meta) { + params.permissions.meta = meta; + } + if (authorizedUserId) { + params.permissions.uuid = "".concat(authorizedUserId); // ensure this is a string + } + return params; + } + function prepareMessagePayload$2(_modules, incomingParams) { + if (hasVspTerms(incomingParams)) { + return prepareMessagePayloadVsp(_modules, incomingParams); + } + var ttl = incomingParams.ttl, resources = incomingParams.resources, patterns = incomingParams.patterns, meta = incomingParams.meta, authorized_uuid = incomingParams.authorized_uuid; + var params = { + ttl: 0, + permissions: { + resources: { + channels: {}, + groups: {}, + uuids: {}, + users: {}, + spaces: {}, // not used, needed for api backward compatibility + }, + patterns: { + channels: {}, + groups: {}, + uuids: {}, + users: {}, + spaces: {}, // not used, needed for api backward compatibility + }, + meta: {}, + }, + }; + if (resources) { + var uuids_1 = resources.uuids, channels_1 = resources.channels, groups_3 = resources.groups; + if (uuids_1) { + Object.keys(uuids_1).forEach(function (uuid) { + params.permissions.resources.uuids[uuid] = extractPermissions(uuids_1[uuid]); + }); + } + if (channels_1) { + Object.keys(channels_1).forEach(function (channel) { + params.permissions.resources.channels[channel] = extractPermissions(channels_1[channel]); + }); + } + if (groups_3) { + Object.keys(groups_3).forEach(function (group) { + params.permissions.resources.groups[group] = extractPermissions(groups_3[group]); + }); + } + } + if (patterns) { + var uuids_2 = patterns.uuids, channels_2 = patterns.channels, groups_4 = patterns.groups; + if (uuids_2) { + Object.keys(uuids_2).forEach(function (uuid) { + params.permissions.patterns.uuids[uuid] = extractPermissions(uuids_2[uuid]); + }); + } + if (channels_2) { + Object.keys(channels_2).forEach(function (channel) { + params.permissions.patterns.channels[channel] = extractPermissions(channels_2[channel]); + }); + } + if (groups_4) { + Object.keys(groups_4).forEach(function (group) { + params.permissions.patterns.groups[group] = extractPermissions(groups_4[group]); + }); + } + } + if (ttl || ttl === 0) { + params.ttl = ttl; + } + if (meta) { + params.permissions.meta = meta; + } + if (authorized_uuid) { + params.permissions.uuid = "".concat(authorized_uuid); // ensure this is a string + } + return params; + } + function validateParams$8(modules, incomingParams) { + var _a, _b, _c, _d, _e, _f; + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + if (!config.publishKey) + return 'Missing Publish Key'; + if (!config.secretKey) + return 'Missing Secret Key'; + if (!incomingParams.resources && !incomingParams.patterns) + return 'Missing either Resources or Patterns.'; + var hasAuthorizedUuid = (incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.authorized_uuid) !== undefined; + var hasUuidResources = ((_a = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _a === void 0 ? void 0 : _a.uuids) !== undefined; + var hasChannelResources = ((_b = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _b === void 0 ? void 0 : _b.channels) !== undefined; + var hasGroupResources = ((_c = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _c === void 0 ? void 0 : _c.groups) !== undefined; + var hasUuidPatterns = ((_d = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _d === void 0 ? void 0 : _d.uuids) !== undefined; + var hasChannelPatterns = ((_e = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _e === void 0 ? void 0 : _e.channels) !== undefined; + var hasGroupPatterns = ((_f = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _f === void 0 ? void 0 : _f.groups) !== undefined; + var hasLegacyTerms = hasAuthorizedUuid || + hasUuidResources || + hasUuidPatterns || + hasChannelResources || + hasChannelPatterns || + hasGroupResources || + hasGroupPatterns; + if (hasVspTerms(incomingParams) && hasLegacyTerms) { + return ('Cannot mix `users`, `spaces` and `authorizedUserId` ' + + 'with `uuids`, `channels`, `groups` and `authorized_uuid`'); + } + if ((incomingParams.resources && + (!incomingParams.resources.uuids || Object.keys(incomingParams.resources.uuids).length === 0) && + (!incomingParams.resources.channels || Object.keys(incomingParams.resources.channels).length === 0) && + (!incomingParams.resources.groups || Object.keys(incomingParams.resources.groups).length === 0) && + (!incomingParams.resources.users || Object.keys(incomingParams.resources.users).length === 0) && + (!incomingParams.resources.spaces || Object.keys(incomingParams.resources.spaces).length === 0)) || + (incomingParams.patterns && + (!incomingParams.patterns.uuids || Object.keys(incomingParams.patterns.uuids).length === 0) && + (!incomingParams.patterns.channels || Object.keys(incomingParams.patterns.channels).length === 0) && + (!incomingParams.patterns.groups || Object.keys(incomingParams.patterns.groups).length === 0) && + (!incomingParams.patterns.users || Object.keys(incomingParams.patterns.users).length === 0) && + (!incomingParams.patterns.spaces || Object.keys(incomingParams.patterns.spaces).length === 0))) { + return 'Missing values for either Resources or Patterns.'; + } + } + function postURL$1(modules) { + var config = modules.config; + return "/v3/pam/".concat(config.subscribeKey, "/grant"); + } + function usePost$1() { + return true; + } + function getRequestTimeout$8(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$8() { + return false; + } + function prepareParams$8() { + return {}; + } + function postPayload$1(modules, incomingParams) { + return prepareMessagePayload$2(modules, incomingParams); + } + function handleResponse$8(modules, response) { + var token = response.data.token; + return token; + } + + var grantTokenEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$8, + extractPermissions: extractPermissions, + validateParams: validateParams$8, + postURL: postURL$1, + usePost: usePost$1, + getRequestTimeout: getRequestTimeout$8, + isAuthSupported: isAuthSupported$8, + prepareParams: prepareParams$8, + postPayload: postPayload$1, + handleResponse: handleResponse$8 + }); + + /** */ + var endpoint$2 = { + getOperation: function () { return OPERATIONS.PNAccessManagerRevokeToken; }, + validateParams: function (modules, token) { + var secretKey = modules.config.secretKey; + if (!secretKey) { + return 'Missing Secret Key'; + } + if (!token) { + return "token can't be empty"; + } + }, + getURL: function (_a, token) { + var config = _a.config; + return "/v3/pam/".concat(config.subscribeKey, "/grant/").concat(utils$5.encodeString(token)); + }, + useDelete: function () { return true; }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getTransactionTimeout(); + }, + isAuthSupported: function () { return false; }, + prepareParams: function (_a) { + var config = _a.config; + return ({ + uuid: config.getUUID(), + }); + }, + handleResponse: function (_, response) { return ({ + status: response.status, + data: response.data, + }); }, + }; + + /* */ + function prepareMessagePayload$1(modules, messagePayload) { + var crypto = modules.crypto, config = modules.config; + var stringifiedPayload = JSON.stringify(messagePayload); + if (config.cipherKey) { + stringifiedPayload = crypto.encrypt(stringifiedPayload); + stringifiedPayload = JSON.stringify(stringifiedPayload); + } + return stringifiedPayload; + } + function getOperation$7() { + return OPERATIONS.PNPublishOperation; + } + function validateParams$7(_a, incomingParams) { + var config = _a.config; + var message = incomingParams.message, channel = incomingParams.channel; + if (!channel) + return 'Missing Channel'; + if (!message) + return 'Missing Message'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function usePost(modules, incomingParams) { + var _a = incomingParams.sendByPost, sendByPost = _a === void 0 ? false : _a; + return sendByPost; + } + function getURL$7(modules, incomingParams) { + var config = modules.config; + var channel = incomingParams.channel, message = incomingParams.message; + var stringifiedPayload = prepareMessagePayload$1(modules, message); + return "/publish/".concat(config.publishKey, "/").concat(config.subscribeKey, "/0/").concat(utils$5.encodeString(channel), "/0/").concat(utils$5.encodeString(stringifiedPayload)); + } + function postURL(modules, incomingParams) { + var config = modules.config; + var channel = incomingParams.channel; + return "/publish/".concat(config.publishKey, "/").concat(config.subscribeKey, "/0/").concat(utils$5.encodeString(channel), "/0"); + } + function getRequestTimeout$7(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$7() { + return true; + } + function postPayload(modules, incomingParams) { + var message = incomingParams.message; + return prepareMessagePayload$1(modules, message); + } + function prepareParams$7(modules, incomingParams) { + var meta = incomingParams.meta, _a = incomingParams.replicate, replicate = _a === void 0 ? true : _a, storeInHistory = incomingParams.storeInHistory, ttl = incomingParams.ttl; + var params = {}; + if (storeInHistory != null) { + if (storeInHistory) { + params.store = '1'; + } + else { + params.store = '0'; + } + } + if (ttl) { + params.ttl = ttl; + } + if (replicate === false) { + params.norep = 'true'; + } + if (meta && typeof meta === 'object') { + params.meta = JSON.stringify(meta); + } + return params; + } + function handleResponse$7(modules, serverResponse) { + return { timetoken: serverResponse[2] }; + } + + var publishEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$7, + validateParams: validateParams$7, + usePost: usePost, + getURL: getURL$7, + postURL: postURL, + getRequestTimeout: getRequestTimeout$7, + isAuthSupported: isAuthSupported$7, + postPayload: postPayload, + prepareParams: prepareParams$7, + handleResponse: handleResponse$7 + }); + + /* */ + function prepareMessagePayload(modules, messagePayload) { + var stringifiedPayload = JSON.stringify(messagePayload); + return stringifiedPayload; + } + function getOperation$6() { + return OPERATIONS.PNSignalOperation; + } + function validateParams$6(_a, incomingParams) { + var config = _a.config; + var message = incomingParams.message, channel = incomingParams.channel; + if (!channel) + return 'Missing Channel'; + if (!message) + return 'Missing Message'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$6(modules, incomingParams) { + var config = modules.config; + var channel = incomingParams.channel, message = incomingParams.message; + var stringifiedPayload = prepareMessagePayload(modules, message); + return "/signal/".concat(config.publishKey, "/").concat(config.subscribeKey, "/0/").concat(utils$5.encodeString(channel), "/0/").concat(utils$5.encodeString(stringifiedPayload)); + } + function getRequestTimeout$6(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$6() { + return true; + } + function prepareParams$6() { + var params = {}; + return params; + } + function handleResponse$6(modules, serverResponse) { + return { timetoken: serverResponse[2] }; + } + + var signalEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$6, + validateParams: validateParams$6, + getURL: getURL$6, + getRequestTimeout: getRequestTimeout$6, + isAuthSupported: isAuthSupported$6, + prepareParams: prepareParams$6, + handleResponse: handleResponse$6 + }); + + /* */ + function __processMessage$1(modules, message) { + var config = modules.config, crypto = modules.crypto; + if (!config.cipherKey) + return message; + try { + return crypto.decrypt(message); + } + catch (e) { + return message; + } + } + function getOperation$5() { + return OPERATIONS.PNHistoryOperation; + } + function validateParams$5(modules, incomingParams) { + var channel = incomingParams.channel; + var config = modules.config; + if (!channel) + return 'Missing channel'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$5(modules, incomingParams) { + var channel = incomingParams.channel; + var config = modules.config; + return "/v2/history/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel)); + } + function getRequestTimeout$5(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$5() { + return true; + } + function prepareParams$5(modules, incomingParams) { + var start = incomingParams.start, end = incomingParams.end, reverse = incomingParams.reverse, _a = incomingParams.count, count = _a === void 0 ? 100 : _a, _b = incomingParams.stringifiedTimeToken, stringifiedTimeToken = _b === void 0 ? false : _b, _c = incomingParams.includeMeta, includeMeta = _c === void 0 ? false : _c; + var outgoingParams = { + include_token: 'true', + }; + outgoingParams.count = count; + if (start) + outgoingParams.start = start; + if (end) + outgoingParams.end = end; + if (stringifiedTimeToken) + outgoingParams.string_message_token = 'true'; + if (reverse != null) + outgoingParams.reverse = reverse.toString(); + if (includeMeta) + outgoingParams.include_meta = 'true'; + return outgoingParams; + } + function handleResponse$5(modules, serverResponse) { + var response = { + messages: [], + startTimeToken: serverResponse[1], + endTimeToken: serverResponse[2], + }; + if (Array.isArray(serverResponse[0])) { + serverResponse[0].forEach(function (serverHistoryItem) { + var item = { + timetoken: serverHistoryItem.timetoken, + entry: __processMessage$1(modules, serverHistoryItem.message), + }; + if (serverHistoryItem.meta) { + item.meta = serverHistoryItem.meta; + } + response.messages.push(item); + }); + } + return response; + } + + var historyEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$5, + validateParams: validateParams$5, + getURL: getURL$5, + getRequestTimeout: getRequestTimeout$5, + isAuthSupported: isAuthSupported$5, + prepareParams: prepareParams$5, + handleResponse: handleResponse$5 + }); + + /* */ + function getOperation$4() { + return OPERATIONS.PNDeleteMessagesOperation; + } + function validateParams$4(modules, incomingParams) { + var channel = incomingParams.channel; + var config = modules.config; + if (!channel) + return 'Missing channel'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function useDelete() { + return true; + } + function getURL$4(modules, incomingParams) { + var channel = incomingParams.channel; + var config = modules.config; + return "/v3/history/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel)); + } + function getRequestTimeout$4(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$4() { + return true; + } + function prepareParams$4(modules, incomingParams) { + var start = incomingParams.start, end = incomingParams.end; + var outgoingParams = {}; + if (start) + outgoingParams.start = start; + if (end) + outgoingParams.end = end; + return outgoingParams; + } + function handleResponse$4(modules, serverResponse) { + return serverResponse.payload; + } + + var deleteMessagesEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$4, + validateParams: validateParams$4, + useDelete: useDelete, + getURL: getURL$4, + getRequestTimeout: getRequestTimeout$4, + isAuthSupported: isAuthSupported$4, + prepareParams: prepareParams$4, + handleResponse: handleResponse$4 + }); + + /* */ + function getOperation$3() { + return OPERATIONS.PNMessageCounts; + } + function validateParams$3(modules, incomingParams) { + var channels = incomingParams.channels, timetoken = incomingParams.timetoken, channelTimetokens = incomingParams.channelTimetokens; + var config = modules.config; + if (!channels) + return 'Missing channel'; + if (timetoken && channelTimetokens) + return 'timetoken and channelTimetokens are incompatible together'; + if (timetoken && channelTimetokens && channelTimetokens.length > 1 && channels.length !== channelTimetokens.length) { + return 'Length of channelTimetokens and channels do not match'; + } + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL$3(modules, incomingParams) { + var channels = incomingParams.channels; + var config = modules.config; + var stringifiedChannels = channels.join(','); + return "/v3/history/sub-key/".concat(config.subscribeKey, "/message-counts/").concat(utils$5.encodeString(stringifiedChannels)); + } + function getRequestTimeout$3(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$3() { + return true; + } + function prepareParams$3(modules, incomingParams) { + var timetoken = incomingParams.timetoken, channelTimetokens = incomingParams.channelTimetokens; + var outgoingParams = {}; + if (channelTimetokens && channelTimetokens.length === 1) { + var _a = __read(channelTimetokens, 1), tt = _a[0]; + outgoingParams.timetoken = tt; + } + else if (channelTimetokens) { + outgoingParams.channelsTimetoken = channelTimetokens.join(','); + } + else if (timetoken) { + outgoingParams.timetoken = timetoken; + } + return outgoingParams; + } + function handleResponse$3(modules, serverResponse) { + return { channels: serverResponse.channels }; + } + + var messageCountsEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$3, + validateParams: validateParams$3, + getURL: getURL$3, + getRequestTimeout: getRequestTimeout$3, + isAuthSupported: isAuthSupported$3, + prepareParams: prepareParams$3, + handleResponse: handleResponse$3 + }); + + /* */ + function __processMessage(modules, message) { + var config = modules.config, crypto = modules.crypto; + if (!config.cipherKey) + return message; + try { + return crypto.decrypt(message); + } + catch (e) { + return message; + } + } + function getOperation$2() { + return OPERATIONS.PNFetchMessagesOperation; + } + function validateParams$2(modules, incomingParams) { + var channels = incomingParams.channels, _a = incomingParams.includeMessageActions, includeMessageActions = _a === void 0 ? false : _a; + var config = modules.config; + if (!channels || channels.length === 0) + return 'Missing channels'; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + if (includeMessageActions && channels.length > 1) { + throw new TypeError('History can return actions data for a single channel only. ' + + 'Either pass a single channel or disable the includeMessageActions flag.'); + } + } + function getURL$2(modules, incomingParams) { + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.includeMessageActions, includeMessageActions = _b === void 0 ? false : _b; + var config = modules.config; + var endpoint = !includeMessageActions ? 'history' : 'history-with-actions'; + var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; + return "/v3/".concat(endpoint, "/sub-key/").concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels)); + } + function getRequestTimeout$2(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function isAuthSupported$2() { + return true; + } + function prepareParams$2(modules, incomingParams) { + var channels = incomingParams.channels, start = incomingParams.start, end = incomingParams.end, includeMessageActions = incomingParams.includeMessageActions, count = incomingParams.count, _a = incomingParams.stringifiedTimeToken, stringifiedTimeToken = _a === void 0 ? false : _a, _b = incomingParams.includeMeta, includeMeta = _b === void 0 ? false : _b, includeUuid = incomingParams.includeUuid, _c = incomingParams.includeUUID, includeUUID = _c === void 0 ? true : _c, _d = incomingParams.includeMessageType, includeMessageType = _d === void 0 ? true : _d; + var outgoingParams = {}; + if (count) { + outgoingParams.max = count; + } + else { + outgoingParams.max = channels.length > 1 || includeMessageActions === true ? 25 : 100; + } + if (start) + outgoingParams.start = start; + if (end) + outgoingParams.end = end; + if (stringifiedTimeToken) + outgoingParams.string_message_token = 'true'; + if (includeMeta) + outgoingParams.include_meta = 'true'; + if (includeUUID && includeUuid !== false) + outgoingParams.include_uuid = 'true'; + if (includeMessageType) + outgoingParams.include_message_type = 'true'; + return outgoingParams; + } + function handleResponse$2(modules, serverResponse) { + var response = { + channels: {}, + }; + Object.keys(serverResponse.channels || {}).forEach(function (channelName) { + response.channels[channelName] = []; + (serverResponse.channels[channelName] || []).forEach(function (messageEnvelope) { + var announce = {}; + announce.channel = channelName; + announce.timetoken = messageEnvelope.timetoken; + announce.message = __processMessage(modules, messageEnvelope.message); + announce.messageType = messageEnvelope.message_type; + announce.uuid = messageEnvelope.uuid; + if (messageEnvelope.actions) { + announce.actions = messageEnvelope.actions; + // This should be kept for few updates for existing clients consistency. + announce.data = messageEnvelope.actions; + } + if (messageEnvelope.meta) { + announce.meta = messageEnvelope.meta; + } + response.channels[channelName].push(announce); + }); + }); + if (serverResponse.more) { + response.more = serverResponse.more; + } + return response; + } + + var fetchMessagesEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$2, + validateParams: validateParams$2, + getURL: getURL$2, + getRequestTimeout: getRequestTimeout$2, + isAuthSupported: isAuthSupported$2, + prepareParams: prepareParams$2, + handleResponse: handleResponse$2 + }); + + /* */ + function getOperation$1() { + return OPERATIONS.PNTimeOperation; + } + function getURL$1() { + return '/time/0'; + } + function getRequestTimeout$1(_a) { + var config = _a.config; + return config.getTransactionTimeout(); + } + function prepareParams$1() { + return {}; + } + function isAuthSupported$1() { + return false; + } + function handleResponse$1(modules, serverResponse) { + return { + timetoken: serverResponse[0], + }; + } + function validateParams$1() { + // pass + } + + var timeEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation$1, + getURL: getURL$1, + getRequestTimeout: getRequestTimeout$1, + prepareParams: prepareParams$1, + isAuthSupported: isAuthSupported$1, + handleResponse: handleResponse$1, + validateParams: validateParams$1 + }); + + /* */ + function getOperation() { + return OPERATIONS.PNSubscribeOperation; + } + function validateParams(modules) { + var config = modules.config; + if (!config.subscribeKey) + return 'Missing Subscribe Key'; + } + function getURL(modules, incomingParams) { + var config = modules.config; + var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; + var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; + return "/v2/subscribe/".concat(config.subscribeKey, "/").concat(utils$5.encodeString(stringifiedChannels), "/0"); + } + function getRequestTimeout(_a) { + var config = _a.config; + return config.getSubscribeTimeout(); + } + function isAuthSupported() { + return true; + } + function prepareParams(_a, incomingParams) { + var config = _a.config; + var state = incomingParams.state, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b, timetoken = incomingParams.timetoken, filterExpression = incomingParams.filterExpression, region = incomingParams.region; + var params = { + heartbeat: config.getPresenceTimeout(), + }; + if (channelGroups.length > 0) { + params['channel-group'] = channelGroups.join(','); + } + if (filterExpression && filterExpression.length > 0) { + params['filter-expr'] = filterExpression; + } + if (Object.keys(state).length) { + params.state = JSON.stringify(state); + } + if (timetoken) { + params.tt = timetoken; + } + if (region) { + params.tr = region; + } + return params; + } + function handleResponse(modules, serverResponse) { + var messages = []; + serverResponse.m.forEach(function (rawMessage) { + var publishMetaData = { + publishTimetoken: rawMessage.p.t, + region: rawMessage.p.r, + }; + var parsedMessage = { + shard: parseInt(rawMessage.a, 10), + subscriptionMatch: rawMessage.b, + channel: rawMessage.c, + messageType: rawMessage.e, + payload: rawMessage.d, + flags: rawMessage.f, + issuingClientId: rawMessage.i, + subscribeKey: rawMessage.k, + originationTimetoken: rawMessage.o, + userMetadata: rawMessage.u, + publishMetaData: publishMetaData, + }; + messages.push(parsedMessage); + }); + var metadata = { + timetoken: serverResponse.t.t, + region: serverResponse.t.r, + }; + return { messages: messages, metadata: metadata }; + } + + var subscribeEndpointConfig = /*#__PURE__*/Object.freeze({ + __proto__: null, + getOperation: getOperation, + validateParams: validateParams, + getURL: getURL, + getRequestTimeout: getRequestTimeout, + isAuthSupported: isAuthSupported, + prepareParams: prepareParams, + handleResponse: handleResponse + }); + + var endpoint$1 = { + getOperation: function () { return OPERATIONS.PNHandshakeOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channels) && !(params === null || params === void 0 ? void 0 : params.channelGroups)) { + return 'channels and channleGroups both should not be empty'; + } + }, + getURL: function (_a, params) { + var config = _a.config; + var channelsString = params.channels ? params.channels.join(',') : ','; + return "/v2/subscribe/".concat(config.subscribeKey, "/").concat(utils$5.encodeString(channelsString), "/0"); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getSubscribeTimeout(); + }, + isAuthSupported: function () { return true; }, + prepareParams: function (_, params) { + var outParams = {}; + if (params.channelGroups && params.channelGroups.length > 0) { + outParams['channel-group'] = params.channelGroups.join(','); + } + outParams.tt = 0; + return outParams; + }, + handleResponse: function (_, response) { return ({ + region: response.t.r, + timetoken: response.t.t, + }); }, + }; + + var endpoint = { + getOperation: function () { return OPERATIONS.PNReceiveMessagesOperation; }, + validateParams: function (_, params) { + if (!(params === null || params === void 0 ? void 0 : params.channels) && !(params === null || params === void 0 ? void 0 : params.channelGroups)) { + return 'channels and channleGroups both should not be empty'; + } + if (!(params === null || params === void 0 ? void 0 : params.timetoken)) { + return 'timetoken can not be empty'; + } + if (!(params === null || params === void 0 ? void 0 : params.region)) { + return 'region can not be empty'; + } + }, + getURL: function (_a, params) { + var config = _a.config; + var channelsString = params.channels ? params.channels.join(',') : ','; + return "/v2/subscribe/".concat(config.subscribeKey, "/").concat(utils$5.encodeString(channelsString), "/0"); + }, + getRequestTimeout: function (_a) { + var config = _a.config; + return config.getSubscribeTimeout(); + }, + isAuthSupported: function () { return true; }, + getAbortSignal: function (_, params) { return params.abortSignal; }, + prepareParams: function (_, params) { + var outParams = {}; + if (params.channelGroups && params.channelGroups.length > 0) { + outParams['channel-group'] = params.channelGroups.join(','); + } + outParams.tt = params.timetoken; + outParams.tr = params.region; + return outParams; + }, + handleResponse: function (_, response) { + var parsedMessages = []; + response.m.forEach(function (envelope) { + var parsedMessage = { + shard: parseInt(envelope.a, 10), + subscriptionMatch: envelope.b, + channel: envelope.c, + messageType: envelope.e, + payload: envelope.d, + flags: envelope.f, + issuingClientId: envelope.i, + subscribeKey: envelope.k, + originationTimetoken: envelope.o, + publishMetaData: { + timetoken: envelope.p.t, + region: envelope.p.r, + }, + }; + parsedMessages.push(parsedMessage); + }); + return { + messages: parsedMessages, + metadata: { + region: response.t.r, + timetoken: response.t.t, + }, + }; + }, + }; + + var Subject = /** @class */ (function () { + function Subject(sync) { + if (sync === void 0) { sync = false; } + this.sync = sync; + this.listeners = new Set(); + } + Subject.prototype.subscribe = function (listener) { + var _this = this; + this.listeners.add(listener); + return function () { + _this.listeners.delete(listener); + }; + }; + Subject.prototype.notify = function (event) { + var _this = this; + var wrapper = function () { + _this.listeners.forEach(function (listener) { + listener(event); + }); + }; + if (this.sync) { + wrapper(); + } + else { + setTimeout(wrapper, 0); + } + }; + return Subject; + }()); + + /* eslint-disable @typescript-eslint/no-explicit-any */ + var State = /** @class */ (function () { + function State(label) { + this.label = label; + this.transitionMap = new Map(); + this.enterEffects = []; + this.exitEffects = []; + } + State.prototype.transition = function (context, event) { + var _a; + if (this.transitionMap.has(event.type)) { + return (_a = this.transitionMap.get(event.type)) === null || _a === void 0 ? void 0 : _a(context, event); + } + return undefined; + }; + State.prototype.on = function (eventType, transition) { + this.transitionMap.set(eventType, transition); + return this; + }; + State.prototype.with = function (context, effects) { + return [this, context, effects !== null && effects !== void 0 ? effects : []]; + }; + State.prototype.onEnter = function (effect) { + this.enterEffects.push(effect); + return this; + }; + State.prototype.onExit = function (effect) { + this.exitEffects.push(effect); + return this; + }; + return State; + }()); + + /* eslint-disable @typescript-eslint/no-explicit-any */ + var Engine = /** @class */ (function (_super) { + __extends(Engine, _super); + function Engine() { + return _super !== null && _super.apply(this, arguments) || this; + } + Engine.prototype.describe = function (label) { + return new State(label); + }; + Engine.prototype.start = function (initialState, initialContext) { + this.currentState = initialState; + this.currentContext = initialContext; + this.notify({ + type: 'engineStarted', + state: initialState, + context: initialContext, + }); + return; + }; + Engine.prototype.transition = function (event) { + var e_1, _a, e_2, _b, e_3, _c; + if (!this.currentState) { + throw new Error('Start the engine first'); + } + this.notify({ + type: 'eventReceived', + event: event, + }); + var transition = this.currentState.transition(this.currentContext, event); + if (transition) { + var _d = __read(transition, 3), newState = _d[0], newContext = _d[1], effects = _d[2]; + try { + for (var _e = __values(this.currentState.exitEffects), _f = _e.next(); !_f.done; _f = _e.next()) { + var effect = _f.value; + this.notify({ + type: 'invocationDispatched', + invocation: effect(this.currentContext), + }); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_f && !_f.done && (_a = _e.return)) _a.call(_e); + } + finally { if (e_1) throw e_1.error; } + } + var oldState = this.currentState; + this.currentState = newState; + var oldContext = this.currentContext; + this.currentContext = newContext; + this.notify({ + type: 'transitionDone', + fromState: oldState, + fromContext: oldContext, + toState: newState, + toContext: newContext, + event: event, + }); + try { + for (var effects_1 = __values(effects), effects_1_1 = effects_1.next(); !effects_1_1.done; effects_1_1 = effects_1.next()) { + var effect = effects_1_1.value; + this.notify({ + type: 'invocationDispatched', + invocation: effect, + }); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (effects_1_1 && !effects_1_1.done && (_b = effects_1.return)) _b.call(effects_1); + } + finally { if (e_2) throw e_2.error; } + } + try { + for (var _g = __values(this.currentState.enterEffects), _h = _g.next(); !_h.done; _h = _g.next()) { + var effect = _h.value; + this.notify({ + type: 'invocationDispatched', + invocation: effect(this.currentContext), + }); + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_h && !_h.done && (_c = _g.return)) _c.call(_g); + } + finally { if (e_3) throw e_3.error; } + } + } + }; + return Engine; + }(Subject)); + + /* eslint-disable @typescript-eslint/no-explicit-any */ + var Dispatcher = /** @class */ (function () { + function Dispatcher(dependencies) { + this.dependencies = dependencies; + this.instances = new Map(); + this.handlers = new Map(); + } + Dispatcher.prototype.on = function (type, handlerCreator) { + this.handlers.set(type, handlerCreator); + }; + Dispatcher.prototype.dispatch = function (invocation) { + if (invocation.type === 'CANCEL') { + if (this.instances.has(invocation.payload)) { + var instance_1 = this.instances.get(invocation.payload); + instance_1 === null || instance_1 === void 0 ? void 0 : instance_1.cancel(); + this.instances.delete(invocation.payload); + } + return; + } + var handlerCreator = this.handlers.get(invocation.type); + if (!handlerCreator) { + throw new Error("Unhandled invocation '".concat(invocation.type, "'")); + } + var instance = handlerCreator(invocation.payload, this.dependencies); + if (invocation.managed) { + this.instances.set(invocation.type, instance); + } + instance.start(); + }; + Dispatcher.prototype.dispose = function () { + var e_1, _a; + try { + for (var _b = __values(this.instances.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { + var _d = __read(_c.value, 2), key = _d[0], instance = _d[1]; + instance.cancel(); + this.instances.delete(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + }; + return Dispatcher; + }()); + + /* eslint-disable @typescript-eslint/no-explicit-any */ + function createEvent(type, fn) { + var creator = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return { + type: type, + payload: fn === null || fn === void 0 ? void 0 : fn.apply(void 0, __spreadArray([], __read(args), false)), + }; + }; + creator.type = type; + return creator; + } + function createEffect(type, fn) { + var creator = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return { type: type, payload: fn.apply(void 0, __spreadArray([], __read(args), false)), managed: false }; + }; + creator.type = type; + return creator; + } + function createManagedEffect(type, fn) { + var creator = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return { type: type, payload: fn.apply(void 0, __spreadArray([], __read(args), false)), managed: true }; + }; + creator.type = type; + creator.cancel = { type: 'CANCEL', payload: type, managed: false }; + return creator; + } + + var AbortError = /** @class */ (function (_super) { + __extends(AbortError, _super); + function AbortError() { + var _newTarget = this.constructor; + var _this = _super.call(this, 'The operation was aborted.') || this; + _this.name = 'AbortError'; + Object.setPrototypeOf(_this, _newTarget.prototype); + return _this; + } + return AbortError; + }(Error)); + var AbortSignal = /** @class */ (function (_super) { + __extends(AbortSignal, _super); + function AbortSignal() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._aborted = false; + return _this; + } + Object.defineProperty(AbortSignal.prototype, "aborted", { + get: function () { + return this._aborted; + }, + enumerable: false, + configurable: true + }); + AbortSignal.prototype.throwIfAborted = function () { + if (this._aborted) { + throw new AbortError(); + } + }; + AbortSignal.prototype.abort = function () { + this._aborted = true; + this.notify(new AbortError()); + }; + return AbortSignal; + }(Subject)); + + var Handler = /** @class */ (function () { + function Handler(payload, dependencies) { + this.payload = payload; + this.dependencies = dependencies; + } + return Handler; + }()); + var AsyncHandler = /** @class */ (function (_super) { + __extends(AsyncHandler, _super); + function AsyncHandler(payload, dependencies, asyncFunction) { + var _this = _super.call(this, payload, dependencies) || this; + _this.asyncFunction = asyncFunction; + _this.abortSignal = new AbortSignal(); + return _this; + } + AsyncHandler.prototype.start = function () { + this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch(function (error) { + // console.log('Unhandled error:', error); + // swallow the error + }); + }; + AsyncHandler.prototype.cancel = function () { + this.abortSignal.abort(); + }; + return AsyncHandler; + }(Handler)); + var asyncHandler = function (handlerFunction) { + return function (payload, dependencies) { + return new AsyncHandler(payload, dependencies, handlerFunction); + }; + }; + + var handshake = createManagedEffect('HANDSHAKE', function (channels, groups) { return ({ + channels: channels, + groups: groups, + }); }); + var receiveEvents = createManagedEffect('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); + var emitEvents = createEffect('EMIT_MESSAGES', function (events) { return events; }); + var emitStatus = createEffect('EMIT_STATUS', function (status) { return status; }); + var reconnect$1 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); + var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); + + var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ + channels: channels, + groups: groups, + timetoken: timetoken, + }); }); + var disconnect = createEvent('DISCONNECT', function () { return ({}); }); + var reconnect = createEvent('RECONNECT', function () { return ({}); }); + var restore = createEvent('RESTORE', function (channels, groups, timetoken, region) { return ({ + channels: channels, + groups: groups, + timetoken: timetoken, + region: region, + }); }); + var handshakingSuccess = createEvent('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); + var handshakingFailure = createEvent('HANDSHAKE_FAILURE', function (error) { return error; }); + var handshakingReconnectingSuccess = createEvent('HANDSHAKE_RECONNECT_SUCCESS', function (cursor) { return ({ + cursor: cursor, + }); }); + var handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); + var handshakingReconnectingGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', function () { return ({}); }); + var handshakingReconnectingRetry = createEvent('HANDSHAKING_RECONNECTING_RETRY', function () { return ({}); }); + var receivingSuccess = createEvent('RECEIVE_SUCCESS', function (cursor, events) { return ({ + cursor: cursor, + events: events, + }); }); + var receivingFailure = createEvent('RECEIVE_FAILURE', function (error) { return error; }); + var reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ + cursor: cursor, + events: events, + }); }); + var reconnectingFailure = createEvent('RECEIVING_RECONNECTING_FAILURE', function (error) { return error; }); + var reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); + var reconnectingRetry = createEvent('RECEIVING_RECONNECTING_RETRY', function () { return ({}); }); + + var EventEngineDispatcher = /** @class */ (function (_super) { + __extends(EventEngineDispatcher, _super); + function EventEngineDispatcher(engine, dependencies) { + var _this = _super.call(this, dependencies) || this; + _this.on(handshake.type, asyncHandler(function (payload, abortSignal, _a) { + var handshake = _a.handshake; + return __awaiter(_this, void 0, void 0, function () { + var result, e_1; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + abortSignal.throwIfAborted(); + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + return [4 /*yield*/, handshake({ + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + })]; + case 2: + result = _b.sent(); + engine.transition(handshakingSuccess(result)); + return [3 /*break*/, 4]; + case 3: + e_1 = _b.sent(); + if (e_1 instanceof Error && e_1.message === 'Aborted') { + return [2 /*return*/]; + } + if (e_1 instanceof PubNubError) { + return [2 /*return*/, engine.transition(handshakingFailure(e_1))]; + } + return [3 /*break*/, 4]; + case 4: return [2 /*return*/]; + } + }); + }); + })); + _this.on(receiveEvents.type, asyncHandler(function (payload, abortSignal, _a) { + var receiveEvents = _a.receiveEvents; + return __awaiter(_this, void 0, void 0, function () { + var result, error_1; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + abortSignal.throwIfAborted(); + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + return [4 /*yield*/, receiveEvents({ + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + timetoken: payload.cursor.timetoken, + region: payload.cursor.region, + })]; + case 2: + result = _b.sent(); + engine.transition(receivingSuccess(result.metadata, result.messages)); + return [3 /*break*/, 4]; + case 3: + error_1 = _b.sent(); + if (error_1 instanceof Error && error_1.message === 'Aborted') { + return [2 /*return*/]; + } + if (error_1 instanceof PubNubError && !abortSignal.aborted) { + return [2 /*return*/, engine.transition(receivingFailure(error_1))]; + } + return [3 /*break*/, 4]; + case 4: return [2 /*return*/]; + } + }); + }); + })); + _this.on(emitEvents.type, asyncHandler(function (payload, abortSignal, _a) { + var emitEvents = _a.emitEvents; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + if (payload.length > 0) { + emitEvents(payload); + } + return [2 /*return*/]; + }); + }); + })); + _this.on(emitStatus.type, asyncHandler(function (payload, abortSignal, _a) { + var emitStatus = _a.emitStatus; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + emitStatus(payload); + return [2 /*return*/]; + }); + }); + })); + _this.on(reconnect$1.type, asyncHandler(function (payload, abortSignal, _a) { + var receiveEvents = _a.receiveEvents, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; + return __awaiter(_this, void 0, void 0, function () { + var result, error_2; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!shouldRetry(payload.reason, payload.attempts)) { + return [2 /*return*/, engine.transition(reconnectingGiveup())]; + } + abortSignal.throwIfAborted(); + return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; + case 1: + _b.sent(); + abortSignal.throwIfAborted(); + _b.label = 2; + case 2: + _b.trys.push([2, 4, , 5]); + return [4 /*yield*/, receiveEvents({ + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + timetoken: payload.cursor.timetoken, + region: payload.cursor.region, + })]; + case 3: + result = _b.sent(); + return [2 /*return*/, engine.transition(reconnectingSuccess(result.metadata, result.messages))]; + case 4: + error_2 = _b.sent(); + if (error_2 instanceof Error && error_2.message === 'Aborted') { + return [2 /*return*/]; + } + if (error_2 instanceof PubNubError) { + return [2 /*return*/, engine.transition(reconnectingFailure(error_2))]; + } + return [3 /*break*/, 5]; + case 5: return [2 /*return*/]; + } + }); + }); + })); + _this.on(handshakeReconnect.type, asyncHandler(function (payload, abortSignal, _a) { + var handshake = _a.handshake, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; + return __awaiter(_this, void 0, void 0, function () { + var result, error_3; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!shouldRetry(payload.reason, payload.attempts)) { + return [2 /*return*/, engine.transition(handshakingReconnectingGiveup())]; + } + abortSignal.throwIfAborted(); + return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; + case 1: + _b.sent(); + abortSignal.throwIfAborted(); + _b.label = 2; + case 2: + _b.trys.push([2, 4, , 5]); + return [4 /*yield*/, handshake({ + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + })]; + case 3: + result = _b.sent(); + return [2 /*return*/, engine.transition(handshakingReconnectingSuccess(result))]; + case 4: + error_3 = _b.sent(); + if (error_3 instanceof Error && error_3.message === 'Aborted') { + return [2 /*return*/]; + } + if (error_3 instanceof PubNubError) { + return [2 /*return*/, engine.transition(handshakingReconnectingFailure(error_3))]; + } + return [3 /*break*/, 5]; + case 5: return [2 /*return*/]; + } + }); + }); + })); + return _this; + } + return EventEngineDispatcher; + }(Dispatcher)); + + var HandshakeStoppedState = new State('STOPPED'); + HandshakeStoppedState.on(subscriptionChange.type, function (_, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + }); + }); + HandshakeStoppedState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); + + var HandshakeFailureState = new State('HANDSHAKE_FAILURE'); + HandshakeFailureState.onEnter(function (context) { return emitStatus({ category: 'PNNetworkIssuesCategory' }); }); + HandshakeFailureState.on(handshakingReconnectingRetry.type, function (context) { + return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); + }); + HandshakeFailureState.on(disconnect.type, function (context) { + return HandshakeStoppedState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HandshakeFailureState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); + + var ReceiveStoppedState = new State('STOPPED'); + ReceiveStoppedState.on(subscriptionChange.type, function (context, event) { + return ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); + }); + ReceiveStoppedState.on(reconnect.type, function (context) { return ReceivingState.with(__assign({}, context)); }); + + var ReceiveFailureState = new State('RECEIVE_FAILURE'); + ReceiveFailureState.on(reconnectingRetry.type, function (context) { + return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); + }); + ReceiveFailureState.on(disconnect.type, function (context) { + return ReceiveStoppedState.with({ + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }); + }); + + var ReceiveReconnectingState = new State('RECEIVE_RECONNECTING'); + ReceiveReconnectingState.onEnter(function (context) { return reconnect$1(context); }); + ReceiveReconnectingState.onExit(function () { return reconnect$1.cancel; }); + ReceiveReconnectingState.on(reconnectingSuccess.type, function (context, event) { + return ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: event.payload.cursor, + }, [emitEvents(event.payload.events)]); + }); + ReceiveReconnectingState.on(reconnectingFailure.type, function (context, event) { + return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); + }); + ReceiveReconnectingState.on(reconnectingGiveup.type, function (context) { + return ReceiveFailureState.with({ + groups: context.groups, + channels: context.channels, + cursor: context.cursor, + reason: context.reason, + }, [emitStatus({ category: 'PNDisconnectedCategory' })]); + }); + ReceiveReconnectingState.on(disconnect.type, function (context) { + return ReceiveStoppedState.with({ + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }, [emitStatus({ category: 'PNDisconnectedCategory' })]); + }); + ReceiveReconnectingState.on(restore.type, function (context) { + return ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }); + }); + ReceiveReconnectingState.on(subscriptionChange.type, function (context, event) { + return ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); + }); + + var ReceivingState = new State('RECEIVING'); + ReceivingState.onEnter(function (_) { return emitStatus({ category: 'PNConnectedCategory' }); }); + ReceivingState.onEnter(function (context) { return receiveEvents(context.channels, context.groups, context.cursor); }); + ReceivingState.onExit(function () { return receiveEvents.cancel; }); + ReceivingState.on(receivingSuccess.type, function (context, event) { + return ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [emitEvents(event.payload.events)]); + }); + ReceivingState.on(subscriptionChange.type, function (context, event) { + if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { + return UnsubscribedState.with(undefined); + } + return ReceivingState.with(__assign(__assign({}, context), { channels: event.payload.channels, groups: event.payload.groups })); + }); + ReceivingState.on(receivingFailure.type, function (context, event) { + return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); + }); + ReceivingState.on(disconnect.type, function (context) { + return ReceiveStoppedState.with({ + channels: context.channels, + groups: context.groups, + cursor: context.cursor, + }, [emitStatus({ category: 'PNDisconnectedCategory' })]); + }); + + var HandshakeReconnectingState = new State('HANDSHAKE_RECONNECTING'); + HandshakeReconnectingState.onEnter(function (context) { return handshakeReconnect(context); }); + HandshakeReconnectingState.onExit(function () { return handshakeReconnect.cancel; }); + HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, function (context, event) { + return ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: event.payload.cursor, + }); + }); + HandshakeReconnectingState.on(handshakingReconnectingFailure.type, function (context, event) { + return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); + }); + HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, function (context) { + return HandshakeFailureState.with({ + groups: context.groups, + channels: context.channels, + reason: context.reason, + }); + }); + HandshakeReconnectingState.on(disconnect.type, function (context) { + return HandshakeStoppedState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + }); + + var HandshakingState = new State('HANDSHAKING'); + HandshakingState.onEnter(function (context) { return handshake(context.channels, context.groups); }); + HandshakingState.onExit(function () { return handshake.cancel; }); + HandshakingState.on(subscriptionChange.type, function (context, event) { + if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { + return UnsubscribedState.with(undefined); + } + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + }); + HandshakingState.on(handshakingSuccess.type, function (context, event) { + return ReceivingState.with({ + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + region: event.payload.region, + }, + }); + }); + HandshakingState.on(handshakingFailure.type, function (context, event) { + return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); + }); + HandshakingState.on(disconnect.type, function (context) { + return HandshakeStoppedState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + + var UnsubscribedState = new State('UNSUBSCRIBED'); + UnsubscribedState.on(subscriptionChange.type, function (_, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); + }); + + var EventEngine = /** @class */ (function () { + function EventEngine(dependencies) { + var _this = this; + this.engine = new Engine(); + this.channels = []; + this.groups = []; + this.dispatcher = new EventEngineDispatcher(this.engine, dependencies); + this._unsubscribeEngine = this.engine.subscribe(function (change) { + if (change.type === 'invocationDispatched') { + _this.dispatcher.dispatch(change.invocation); + } + }); + this.engine.start(UnsubscribedState, undefined); + } + Object.defineProperty(EventEngine.prototype, "_engine", { + get: function () { + return this.engine; + }, + enumerable: false, + configurable: true + }); + EventEngine.prototype.subscribe = function (_a) { + var channels = _a.channels, groups = _a.groups, timetoken = _a.timetoken; + this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); + this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); + this.engine.transition(subscriptionChange(this.channels, this.groups, timetoken !== null && timetoken !== void 0 ? timetoken : '0')); + }; + EventEngine.prototype.unsubscribe = function (_a) { + var channels = _a.channels, groups = _a.groups; + this.channels = this.channels.filter(function (channel) { var _a; return (_a = !(channels === null || channels === void 0 ? void 0 : channels.includes(channel))) !== null && _a !== void 0 ? _a : true; }); + this.groups = this.groups.filter(function (group) { var _a; return (_a = !(groups === null || groups === void 0 ? void 0 : groups.includes(group))) !== null && _a !== void 0 ? _a : true; }); + this.engine.transition(subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + }; + EventEngine.prototype.unsubscribeAll = function () { + this.channels = []; + this.groups = []; + this.engine.transition(subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + }; + EventEngine.prototype.reconnect = function () { + this.engine.transition(reconnect()); + }; + EventEngine.prototype.disconnect = function () { + this.engine.transition(disconnect()); + }; + EventEngine.prototype.dispose = function () { + this.disconnect(); + this._unsubscribeEngine(); + this.dispatcher.dispose(); + }; + return EventEngine; + }()); + + var ReconnectionDelay = /** @class */ (function () { + function ReconnectionDelay() { + } + ReconnectionDelay.getDelay = function (policy, attempts, backoff) { + var backoffValue = backoff !== null && backoff !== void 0 ? backoff : 5; + switch (policy.toUpperCase()) { + case 'LINEAR': + return attempts * backoffValue + Math.random() * 1000; + case 'EXPONENTIAL': + return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; + default: + throw new Error('invalid policy'); + } + }; + return ReconnectionDelay; + }()); + + var default_1$3 = /** @class */ (function () { + // + function default_1(setup) { + var _this = this; + var _a; + var networking = setup.networking, cbor = setup.cbor; + var config = new default_1$b({ setup: setup }); + this._config = config; + var crypto = new default_1$a({ config: config }); // LEGACY + var cryptography = setup.cryptography; + networking.init(config); + var tokenManager = new default_1$4(config, cbor); + this._tokenManager = tokenManager; + var telemetryManager = new default_1$6({ + maximumSamplesCount: 60000, + }); + this._telemetryManager = telemetryManager; + var modules = { + config: config, + networking: networking, + crypto: crypto, + cryptography: cryptography, + tokenManager: tokenManager, + telemetryManager: telemetryManager, + PubNubFile: setup.PubNubFile, + }; + this.File = setup.PubNubFile; + this.encryptFile = function (key, file) { return cryptography.encryptFile(key, file, _this.File); }; + this.decryptFile = function (key, file) { return cryptography.decryptFile(key, file, _this.File); }; + var timeEndpoint = endpointCreator.bind(this, modules, timeEndpointConfig); + var leaveEndpoint = endpointCreator.bind(this, modules, presenceLeaveEndpointConfig); + var heartbeatEndpoint = endpointCreator.bind(this, modules, presenceHeartbeatEndpointConfig); + var setStateEndpoint = endpointCreator.bind(this, modules, presenceSetStateConfig); + var subscribeEndpoint = endpointCreator.bind(this, modules, subscribeEndpointConfig); + // managers + var listenerManager = new default_1$5(); + this._listenerManager = listenerManager; + this.iAmHere = endpointCreator.bind(this, modules, presenceHeartbeatEndpointConfig); + this.iAmAway = endpointCreator.bind(this, modules, presenceLeaveEndpointConfig); + this.setPresenceState = endpointCreator.bind(this, modules, presenceSetStateConfig); + this.handshake = endpointCreator.bind(this, modules, endpoint$1); + this.receiveMessages = endpointCreator.bind(this, modules, endpoint); + if (config.enableSubscribeBeta === true) { + var policy_1 = modules.config.reconnectionConfiguration.reconnectionPolicy; + var maxRetries_1 = (_a = modules.config.reconnectionConfiguration.maximumReconnectionRetries) !== null && _a !== void 0 ? _a : 0; + var eventEngine = new EventEngine({ + handshake: this.handshake, + receiveEvents: this.receiveMessages, + getRetryDelay: function (attempts) { return ReconnectionDelay.getDelay(policy_1, attempts); }, + delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, + shouldRetry: function (_, attempts) { return maxRetries_1 > attempts && policy_1 && policy_1 != 'None'; }, + emitEvents: function (events) { + var e_1, _a; + try { + for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { + var event_1 = events_1_1.value; + listenerManager.announceMessage(event_1); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1); + } + finally { if (e_1) throw e_1.error; } + } + }, + emitStatus: function (status) { + listenerManager.announceStatus(status); + }, + }); + this.subscribe = eventEngine.subscribe.bind(eventEngine); + this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); + this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); + this.reconnect = eventEngine.reconnect.bind(eventEngine); + this.disconnect = eventEngine.disconnect.bind(eventEngine); + this.eventEngine = eventEngine; + } + else { + var subscriptionManager_1 = new default_1$7({ + timeEndpoint: timeEndpoint, + leaveEndpoint: leaveEndpoint, + heartbeatEndpoint: heartbeatEndpoint, + setStateEndpoint: setStateEndpoint, + subscribeEndpoint: subscribeEndpoint, + crypto: modules.crypto, + config: modules.config, + listenerManager: listenerManager, + getFileUrl: function (params) { return getFileUrlFunction(modules, params); }, + }); + this.subscribe = subscriptionManager_1.adaptSubscribeChange.bind(subscriptionManager_1); + this.unsubscribe = subscriptionManager_1.adaptUnsubscribeChange.bind(subscriptionManager_1); + this.disconnect = subscriptionManager_1.disconnect.bind(subscriptionManager_1); + this.reconnect = subscriptionManager_1.reconnect.bind(subscriptionManager_1); + this.unsubscribeAll = subscriptionManager_1.unsubscribeAll.bind(subscriptionManager_1); + this.getSubscribedChannels = subscriptionManager_1.getSubscribedChannels.bind(subscriptionManager_1); + this.getSubscribedChannelGroups = subscriptionManager_1.getSubscribedChannelGroups.bind(subscriptionManager_1); + this.setState = subscriptionManager_1.adaptStateChange.bind(subscriptionManager_1); + this.presence = subscriptionManager_1.adaptPresenceChange.bind(subscriptionManager_1); + this.destroy = function (isOffline) { + subscriptionManager_1.unsubscribeAll(isOffline); + subscriptionManager_1.disconnect(); + }; + } + this.addListener = listenerManager.addListener.bind(listenerManager); + this.removeListener = listenerManager.removeListener.bind(listenerManager); + this.removeAllListeners = listenerManager.removeAllListeners.bind(listenerManager); + this.parseToken = tokenManager.parseToken.bind(tokenManager); + this.setToken = tokenManager.setToken.bind(tokenManager); + this.getToken = tokenManager.getToken.bind(tokenManager); + /* channel groups */ + this.channelGroups = { + listGroups: endpointCreator.bind(this, modules, listChannelGroupsConfig), + listChannels: endpointCreator.bind(this, modules, listChannelsInChannelGroupConfig), + addChannels: endpointCreator.bind(this, modules, addChannelsChannelGroupConfig), + removeChannels: endpointCreator.bind(this, modules, removeChannelsChannelGroupConfig), + deleteGroup: endpointCreator.bind(this, modules, deleteChannelGroupConfig), + }; + /* push */ + this.push = { + addChannels: endpointCreator.bind(this, modules, addPushChannelsConfig), + removeChannels: endpointCreator.bind(this, modules, removePushChannelsConfig), + deleteDevice: endpointCreator.bind(this, modules, removeDevicePushConfig), + listChannels: endpointCreator.bind(this, modules, listPushChannelsConfig), + }; + /* presence */ + this.hereNow = endpointCreator.bind(this, modules, presenceHereNowConfig); + this.whereNow = endpointCreator.bind(this, modules, presenceWhereNowEndpointConfig); + this.getState = endpointCreator.bind(this, modules, presenceGetStateConfig); + /* PAM */ + this.grant = endpointCreator.bind(this, modules, grantEndpointConfig); + this.grantToken = endpointCreator.bind(this, modules, grantTokenEndpointConfig); + this.audit = endpointCreator.bind(this, modules, auditEndpointConfig); + this.revokeToken = endpointCreator.bind(this, modules, endpoint$2); + this.publish = endpointCreator.bind(this, modules, publishEndpointConfig); + this.fire = function (args, callback) { + args.replicate = false; + args.storeInHistory = false; + return _this.publish(args, callback); + }; + this.signal = endpointCreator.bind(this, modules, signalEndpointConfig); + this.history = endpointCreator.bind(this, modules, historyEndpointConfig); + this.deleteMessages = endpointCreator.bind(this, modules, deleteMessagesEndpointConfig); + this.messageCounts = endpointCreator.bind(this, modules, messageCountsEndpointConfig); + this.fetchMessages = endpointCreator.bind(this, modules, fetchMessagesEndpointConfig); + // Actions API + this.addMessageAction = endpointCreator.bind(this, modules, addMessageActionEndpointConfig); + this.removeMessageAction = endpointCreator.bind(this, modules, removeMessageActionEndpointConfig); + this.getMessageActions = endpointCreator.bind(this, modules, getMessageActionEndpointConfig); + // File Upload API v1 + this.listFiles = endpointCreator.bind(this, modules, endpoint$j); + var generateUploadUrl = endpointCreator.bind(this, modules, endpoint$i); + this.publishFile = endpointCreator.bind(this, modules, endpoint$h); + this.sendFile = sendFileFunction({ + generateUploadUrl: generateUploadUrl, + publishFile: this.publishFile, + modules: modules, + }); + this.getFileUrl = function (params) { return getFileUrlFunction(modules, params); }; + this.downloadFile = endpointCreator.bind(this, modules, endpoint$g); + this.deleteFile = endpointCreator.bind(this, modules, endpoint$f); + // Objects API v2 + this.objects = { + getAllUUIDMetadata: endpointCreator.bind(this, modules, endpoint$e), + getUUIDMetadata: endpointCreator.bind(this, modules, endpoint$d), + setUUIDMetadata: endpointCreator.bind(this, modules, endpoint$c), + removeUUIDMetadata: endpointCreator.bind(this, modules, endpoint$b), + getAllChannelMetadata: endpointCreator.bind(this, modules, endpoint$a), + getChannelMetadata: endpointCreator.bind(this, modules, endpoint$9), + setChannelMetadata: endpointCreator.bind(this, modules, endpoint$8), + removeChannelMetadata: endpointCreator.bind(this, modules, endpoint$7), + getChannelMembers: endpointCreator.bind(this, modules, endpoint$6), + setChannelMembers: function (parameters) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, + modules, + endpoint$5, __assign({ type: 'set' }, parameters)], __read(rest), false)); + }, + removeChannelMembers: function (parameters) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, + modules, + endpoint$5, __assign({ type: 'delete' }, parameters)], __read(rest), false)); + }, + getMemberships: endpointCreator.bind(this, modules, endpoint$4), + setMemberships: function (parameters) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, + modules, + endpoint$3, __assign({ type: 'set' }, parameters)], __read(rest), false)); + }, + removeMemberships: function (parameters) { + var rest = []; + for (var _i = 1; _i < arguments.length; _i++) { + rest[_i - 1] = arguments[_i]; + } + return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, + modules, + endpoint$3, __assign({ type: 'delete' }, parameters)], __read(rest), false)); + }, + }; + // User Apis + this.createUser = function (args) { + return _this.objects.setUUIDMetadata({ + uuid: args.userId, + data: args.data, + include: args.include, + }); + }; + this.updateUser = this.createUser; + this.removeUser = function (args) { + return _this.objects.removeUUIDMetadata({ + uuid: args === null || args === void 0 ? void 0 : args.userId, + }); + }; + this.fetchUser = function (args) { + return _this.objects.getUUIDMetadata({ + uuid: args === null || args === void 0 ? void 0 : args.userId, + include: args === null || args === void 0 ? void 0 : args.include, + }); + }; + this.fetchUsers = this.objects.getAllUUIDMetadata; + // Space apis + this.createSpace = function (args) { + return _this.objects.setChannelMetadata({ + channel: args.spaceId, + data: args.data, + include: args.include, + }); + }; + this.updateSpace = this.createSpace; + this.removeSpace = function (args) { + return _this.objects.removeChannelMetadata({ + channel: args.spaceId, + }); + }; + this.fetchSpace = function (args) { + return _this.objects.getChannelMetadata({ + channel: args.spaceId, + include: args.include, + }); + }; + this.fetchSpaces = this.objects.getAllChannelMetadata; + // Membership apis + this.addMemberships = function (parameters) { + var _a, _b; + if (typeof parameters.spaceId === 'string') { + return _this.objects.setChannelMembers({ + channel: parameters.spaceId, + uuids: (_a = parameters.users) === null || _a === void 0 ? void 0 : _a.map(function (user) { + if (typeof user === 'string') { + return user; + } + return { + id: user.userId, + custom: user.custom, + status: user.status, + }; + }), + limit: 0, + }); + } + else { + return _this.objects.setMemberships({ + uuid: parameters.userId, + channels: (_b = parameters.spaces) === null || _b === void 0 ? void 0 : _b.map(function (space) { + if (typeof space === 'string') { + return space; + } + return { + id: space.spaceId, + custom: space.custom, + status: space.status, + }; + }), + limit: 0, + }); + } + }; + this.updateMemberships = this.addMemberships; + this.removeMemberships = function (parameters) { + if (typeof parameters.spaceId === 'string') { + return _this.objects.removeChannelMembers({ + channel: parameters.spaceId, + uuids: parameters.userIds, + limit: 0, + }); + } + else { + return _this.objects.removeMemberships({ + uuid: parameters.userId, + channels: parameters.spaceIds, + limit: 0, + }); + } + }; + this.fetchMemberships = function (params) { + if (typeof params.spaceId === 'string') { + return _this.objects + .getChannelMembers({ + channel: params.spaceId, + filter: params.filter, + limit: params.limit, + page: params.page, + include: { + customFields: params.include.customFields, + UUIDFields: params.include.userFields, + customUUIDFields: params.include.customUserFields, + totalCount: params.include.totalCount, + }, + sort: params.sort != null + ? Object.fromEntries(Object.entries(params.sort).map(function (_a) { + var _b = __read(_a, 2), k = _b[0], v = _b[1]; + return [k.replace('user', 'uuid'), v]; + })) + : null, + }) + .then(function (res) { + var _a; + res.data = (_a = res.data) === null || _a === void 0 ? void 0 : _a.map(function (m) { + return { + user: m.uuid, + custom: m.custom, + updated: m.updated, + eTag: m.eTag, + }; + }); + return res; + }); + } + else { + return _this.objects + .getMemberships({ + uuid: params.userId, + filter: params.filter, + limit: params.limit, + page: params.page, + include: { + customFields: params.include.customFields, + channelFields: params.include.spaceFields, + customChannelFields: params.include.customSpaceFields, + totalCount: params.include.totalCount, + }, + sort: params.sort != null + ? Object.fromEntries(Object.entries(params.sort).map(function (_a) { + var _b = __read(_a, 2), k = _b[0], v = _b[1]; + return [k.replace('space', 'channel'), v]; + })) + : null, + }) + .then(function (res) { + var _a; + res.data = (_a = res.data) === null || _a === void 0 ? void 0 : _a.map(function (m) { + return { + space: m.channel, + custom: m.custom, + updated: m.updated, + eTag: m.eTag, + }; + }); + return res; + }); + } + }; + this.time = timeEndpoint; + // --- deprecated ------------------ + this.stop = this.destroy; // -------- + // --- deprecated ------------------ + // mount crypto + this.encrypt = crypto.encrypt.bind(crypto); + this.decrypt = crypto.decrypt.bind(crypto); + /* config */ + this.getAuthKey = modules.config.getAuthKey.bind(modules.config); + this.setAuthKey = modules.config.setAuthKey.bind(modules.config); + this.setCipherKey = modules.config.setCipherKey.bind(modules.config); + this.getUUID = modules.config.getUUID.bind(modules.config); + this.setUUID = modules.config.setUUID.bind(modules.config); + this.getFilterExpression = modules.config.getFilterExpression.bind(modules.config); + this.setFilterExpression = modules.config.setFilterExpression.bind(modules.config); + this.setHeartbeatInterval = modules.config.setHeartbeatInterval.bind(modules.config); + if (networking.hasModule('proxy')) { + this.setProxy = function (proxy) { + modules.config.setProxy(proxy); + _this.reconnect(); + }; + } + } + default_1.prototype.getVersion = function () { + return this._config.getVersion(); + }; + default_1.prototype._addPnsdkSuffix = function (name, suffix) { + this._config._addPnsdkSuffix(name, suffix); + }; + // network hooks to indicate network changes + default_1.prototype.networkDownDetected = function () { + this._listenerManager.announceNetworkDown(); + if (this._config.restore) { + this.disconnect(); + } + else { + this.destroy(true); + } + }; + default_1.prototype.networkUpDetected = function () { + this._listenerManager.announceNetworkUp(); + this.reconnect(); + }; + default_1.notificationPayload = function (title, body) { + return new NotificationsPayload(title, body); + }; + default_1.generateUUID = function () { + return uuidGenerator.createUUID(); + }; + default_1.OPERATIONS = OPERATIONS; + default_1.CATEGORIES = categories; + return default_1; + }()); + + /* */ + var default_1$2 = /** @class */ (function () { + function default_1(modules) { + var _this = this; + this._modules = {}; + Object.keys(modules).forEach(function (key) { + _this._modules[key] = modules[key].bind(_this); + }); + } + default_1.prototype.init = function (config) { + this._config = config; + if (Array.isArray(this._config.origin)) { + this._currentSubDomain = Math.floor(Math.random() * this._config.origin.length); + } + else { + this._currentSubDomain = 0; + } + this._coreParams = {}; + // create initial origins + this.shiftStandardOrigin(); + }; + default_1.prototype.nextOrigin = function () { + var protocol = this._config.secure ? 'https://' : 'http://'; + if (typeof this._config.origin === 'string') { + return "".concat(protocol).concat(this._config.origin); + } + this._currentSubDomain += 1; + if (this._currentSubDomain >= this._config.origin.length) { + this._currentSubDomain = 0; + } + var origin = this._config.origin[this._currentSubDomain]; + return "".concat(protocol).concat(origin); + }; + default_1.prototype.hasModule = function (name) { + return name in this._modules; + }; + // origin operations + default_1.prototype.shiftStandardOrigin = function () { + this._standardOrigin = this.nextOrigin(); + return this._standardOrigin; + }; + default_1.prototype.getStandardOrigin = function () { + return this._standardOrigin; + }; + default_1.prototype.POSTFILE = function (url, fields, file) { + return this._modules.postfile(url, fields, file); + }; + default_1.prototype.GETFILE = function (params, endpoint, callback) { + return this._modules.getfile(params, endpoint, callback); + }; + default_1.prototype.POST = function (params, body, endpoint, callback) { + return this._modules.post(params, body, endpoint, callback); + }; + default_1.prototype.PATCH = function (params, body, endpoint, callback) { + return this._modules.patch(params, body, endpoint, callback); + }; + default_1.prototype.GET = function (params, endpoint, callback) { + return this._modules.get(params, endpoint, callback); + }; + default_1.prototype.DELETE = function (params, endpoint, callback) { + return this._modules.del(params, endpoint, callback); + }; + default_1.prototype._detectErrorCategory = function (err) { + if (err.code === 'ENOTFOUND') { + return categories.PNNetworkIssuesCategory; + } + if (err.code === 'ECONNREFUSED') { + return categories.PNNetworkIssuesCategory; + } + if (err.code === 'ECONNRESET') { + return categories.PNNetworkIssuesCategory; + } + if (err.code === 'EAI_AGAIN') { + return categories.PNNetworkIssuesCategory; + } + if (err.status === 0 || (err.hasOwnProperty('status') && typeof err.status === 'undefined')) { + return categories.PNNetworkIssuesCategory; + } + if (err.timeout) + return categories.PNTimeoutCategory; + if (err.code === 'ETIMEDOUT') { + return categories.PNNetworkIssuesCategory; + } + if (err.response) { + if (err.response.badRequest) { + return categories.PNBadRequestCategory; + } + if (err.response.forbidden) { + return categories.PNAccessDeniedCategory; + } + } + return categories.PNUnknownCategory; + }; + return default_1; + }()); + + function stringifyBufferKeys(obj) { + var isObject = function (value) { return value && typeof value === 'object' && value.constructor === Object; }; + var isString = function (value) { return typeof value === 'string' || value instanceof String; }; + var isNumber = function (value) { return typeof value === 'number' && isFinite(value); }; + if (!isObject(obj)) { + return obj; + } + var normalizedObject = {}; + Object.keys(obj).forEach(function (key) { + var keyIsString = isString(key); + var stringifiedKey = key; + var value = obj[key]; + if (Array.isArray(key) || (keyIsString && key.indexOf(',') >= 0)) { + var bytes = keyIsString ? key.split(',') : key; + stringifiedKey = bytes.reduce(function (string, byte) { + string += String.fromCharCode(byte); + return string; + }, ''); + } + else if (isNumber(key) || (keyIsString && !isNaN(key))) { + stringifiedKey = String.fromCharCode(keyIsString ? parseInt(key, 10) : 10); + } + normalizedObject[stringifiedKey] = isObject(value) ? stringifyBufferKeys(value) : value; + }); + return normalizedObject; + } + + var default_1$1 = /** @class */ (function () { + function default_1(decode, base64ToBinary) { + this._base64ToBinary = base64ToBinary; + this._decode = decode; + } + default_1.prototype.decodeToken = function (tokenString) { + var padding = ''; + if (tokenString.length % 4 === 3) { + padding = '='; + } + else if (tokenString.length % 4 === 2) { + padding = '=='; + } + var cleaned = tokenString.replace(/-/gi, '+').replace(/_/gi, '/') + padding; + var result = this._decode(this._base64ToBinary(cleaned)); + if (typeof result === 'object') { + return result; + } + return undefined; + }; + return default_1; + }()); + + var client = {exports: {}}; + + var componentEmitter = {exports: {}}; + + (function (module) { + /** + * Expose `Emitter`. + */ - var CborReader = cbor.exports; + { + module.exports = Emitter; + } - var uuid = {exports: {}}; + /** + * Initialize a new `Emitter`. + * + * @api public + */ - /*! lil-uuid - v0.1 - MIT License - https://github.com/lil-js/uuid */ + function Emitter(obj) { + if (obj) return mixin(obj); + } + /** + * Mixin the emitter properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ - (function (module, exports) { - (function (root, factory) { - { - factory(exports); - if (module !== null) { - module.exports = exports.uuid; - } + function mixin(obj) { + for (var key in Emitter.prototype) { + obj[key] = Emitter.prototype[key]; } - }(commonjsGlobal, function (exports) { - var VERSION = '0.1.0'; - var uuidRegex = { - '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 - }; + return obj; + } - function uuid() { - var uuid = '', i, random; - for (i = 0; i < 32; i++) { - random = Math.random() * 16 | 0; - if (i === 8 || i === 12 || i === 16 || i === 20) uuid += '-'; - uuid += (i === 12 ? 4 : (i === 16 ? (random & 3 | 8) : random)).toString(16); - } - return uuid - } + /** + * Listen on the given `event` with `fn`. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ + + Emitter.prototype.on = + Emitter.prototype.addEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; + (this._callbacks['$' + event] = this._callbacks['$' + event] || []) + .push(fn); + return this; + }; + + /** + * Adds an `event` listener that will be invoked a single + * time then automatically removed. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ - function isUUID(str, version) { - var pattern = uuidRegex[version || 'all']; - return pattern && pattern.test(str) || false + Emitter.prototype.once = function(event, fn){ + function on() { + this.off(event, on); + fn.apply(this, arguments); } - uuid.isUUID = isUUID; - uuid.VERSION = VERSION; + on.fn = fn; + this.on(event, on); + return this; + }; - exports.uuid = uuid; - exports.isUUID = isUUID; - })); - }(uuid, uuid.exports)); + /** + * Remove the given callback for `event` or all + * registered callbacks. + * + * @param {String} event + * @param {Function} fn + * @return {Emitter} + * @api public + */ - var uuidGenerator$1 = uuid.exports; + Emitter.prototype.off = + Emitter.prototype.removeListener = + Emitter.prototype.removeAllListeners = + Emitter.prototype.removeEventListener = function(event, fn){ + this._callbacks = this._callbacks || {}; - var uuidGenerator = { - createUUID: function () { - if (uuidGenerator$1.uuid) { - return uuidGenerator$1.uuid(); - } - return uuidGenerator$1(); - }, - }; + // all + if (0 == arguments.length) { + this._callbacks = {}; + return this; + } - /* */ - var PRESENCE_TIMEOUT_MINIMUM = 20; - var PRESENCE_TIMEOUT_DEFAULT = 300; - var makeDefaultOrigins = function () { return Array.from({ length: 20 }, function (_, i) { return "ps".concat(i + 1, ".pndsn.com"); }); }; - var default_1$b = /** @class */ (function () { - function default_1(_a) { - var setup = _a.setup; - var _b, _c, _d; - this._PNSDKSuffix = {}; - this.instanceId = "pn-".concat(uuidGenerator.createUUID()); - this.secretKey = setup.secretKey || setup.secret_key; - this.subscribeKey = setup.subscribeKey || setup.subscribe_key; - this.publishKey = setup.publishKey || setup.publish_key; - this.sdkName = setup.sdkName; - this.sdkFamily = setup.sdkFamily; - this.partnerId = setup.partnerId; - this.setAuthKey(setup.authKey); - this.setCipherKey(setup.cipherKey); - this.setFilterExpression(setup.filterExpression); - if (typeof setup.origin !== 'string' && !Array.isArray(setup.origin) && setup.origin !== undefined) { - throw new Error('Origin must be either undefined, a string or a list of strings.'); - } - this.origin = setup.origin || makeDefaultOrigins(); - this.secure = setup.ssl || false; - this.restore = setup.restore || false; - this.proxy = setup.proxy; - this.keepAlive = setup.keepAlive; - this.keepAliveSettings = setup.keepAliveSettings; - this.autoNetworkDetection = setup.autoNetworkDetection || false; - this.dedupeOnSubscribe = setup.dedupeOnSubscribe || false; - this.maximumCacheSize = setup.maximumCacheSize || 100; - this.customEncrypt = setup.customEncrypt; - this.customDecrypt = setup.customDecrypt; - this.fileUploadPublishRetryLimit = (_b = setup.fileUploadPublishRetryLimit) !== null && _b !== void 0 ? _b : 5; - this.useRandomIVs = (_c = setup.useRandomIVs) !== null && _c !== void 0 ? _c : true; - // flag for beta subscribe feature enablement - this.enableSubscribeBeta = (_d = setup.enableSubscribeBeta) !== null && _d !== void 0 ? _d : false; - // reconnection configuration settings to apply reconnection settings in subscription - this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; - // if location config exist and we are in https, force secure to true. - if (typeof location !== 'undefined' && location.protocol === 'https:') { - this.secure = true; - } - this.logVerbosity = setup.logVerbosity || false; - this.suppressLeaveEvents = setup.suppressLeaveEvents || false; - this.announceFailedHeartbeats = setup.announceFailedHeartbeats || true; - this.announceSuccessfulHeartbeats = setup.announceSuccessfulHeartbeats || false; - this.useInstanceId = setup.useInstanceId || false; - this.useRequestId = setup.useRequestId || false; - this.requestMessageCountThreshold = setup.requestMessageCountThreshold; - // set timeout to how long a transaction request will wait for the server (default 15 seconds) - this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000); - // set timeout to how long a subscribe event loop will run (default 310 seconds) - this.setSubscribeTimeout(setup.subscribeRequestTimeout || 310 * 1000); - // set config on beacon (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon) usage - this.setSendBeaconConfig(setup.useSendBeacon || true); - // how long the SDK will report the client to be alive before issuing a timeout - if (setup.presenceTimeout) { - this.setPresenceTimeout(setup.presenceTimeout); - } - else { - this._presenceTimeout = PRESENCE_TIMEOUT_DEFAULT; - } - if (setup.heartbeatInterval != null) { - this.setHeartbeatInterval(setup.heartbeatInterval); - } - if (typeof setup.userId === 'string') { - if (typeof setup.uuid === 'string') { - throw new Error('Only one of the following configuration options has to be provided: `uuid` or `userId`'); - } - this.setUserId(setup.userId); - } - else { - if (typeof setup.uuid !== 'string') { - throw new Error('One of the following configuration options has to be provided: `uuid` or `userId`'); - } - this.setUUID(setup.uuid); - } + // specific event + var callbacks = this._callbacks['$' + event]; + if (!callbacks) return this; + + // remove all handlers + if (1 == arguments.length) { + delete this._callbacks['$' + event]; + return this; + } + + // remove specific handler + var cb; + for (var i = 0; i < callbacks.length; i++) { + cb = callbacks[i]; + if (cb === fn || cb.fn === fn) { + callbacks.splice(i, 1); + break; } - // exposed setters - default_1.prototype.getAuthKey = function () { - return this.authKey; - }; - default_1.prototype.setAuthKey = function (val) { - this.authKey = val; - return this; - }; - default_1.prototype.setCipherKey = function (val) { - this.cipherKey = val; - return this; - }; - default_1.prototype.getUUID = function () { - return this.UUID; - }; - default_1.prototype.setUUID = function (val) { - if (!val || typeof val !== 'string' || val.trim().length === 0) { - throw new Error('Missing uuid parameter. Provide a valid string uuid'); - } - this.UUID = val; - return this; - }; - default_1.prototype.getUserId = function () { - return this.UUID; - }; - default_1.prototype.setUserId = function (value) { - if (!value || typeof value !== 'string' || value.trim().length === 0) { - throw new Error('Missing or invalid userId parameter. Provide a valid string userId'); - } - this.UUID = value; - return this; - }; - default_1.prototype.getFilterExpression = function () { - return this.filterExpression; - }; - default_1.prototype.setFilterExpression = function (val) { - this.filterExpression = val; - return this; - }; - default_1.prototype.getPresenceTimeout = function () { - return this._presenceTimeout; - }; - default_1.prototype.setPresenceTimeout = function (val) { - if (val >= PRESENCE_TIMEOUT_MINIMUM) { - this._presenceTimeout = val; - } - else { - this._presenceTimeout = PRESENCE_TIMEOUT_MINIMUM; - // eslint-disable-next-line no-console - console.log('WARNING: Presence timeout is less than the minimum. Using minimum value: ', this._presenceTimeout); - } - this.setHeartbeatInterval(this._presenceTimeout / 2 - 1); - return this; - }; - default_1.prototype.setProxy = function (proxy) { - this.proxy = proxy; - }; - default_1.prototype.getHeartbeatInterval = function () { - return this._heartbeatInterval; - }; - default_1.prototype.setHeartbeatInterval = function (val) { - this._heartbeatInterval = val; - return this; - }; - // deprecated setters. - default_1.prototype.getSubscribeTimeout = function () { - return this._subscribeRequestTimeout; - }; - default_1.prototype.setSubscribeTimeout = function (val) { - this._subscribeRequestTimeout = val; - return this; - }; - default_1.prototype.getTransactionTimeout = function () { - return this._transactionalRequestTimeout; - }; - default_1.prototype.setTransactionTimeout = function (val) { - this._transactionalRequestTimeout = val; - return this; - }; - default_1.prototype.isSendBeaconEnabled = function () { - return this._useSendBeacon; - }; - default_1.prototype.setSendBeaconConfig = function (val) { - this._useSendBeacon = val; - return this; - }; - default_1.prototype.getVersion = function () { - return '7.2.3'; - }; - default_1.prototype.setReconnectionConfiguration = function (reconnectionPolicy, maximumReconnectionRetries) { - this.reconnectionConfiguration = __assign(__assign({}, config.reconnectionConfiguration), { reconnectionPolicy: reconnectionPolicy, maximumReconnectionRetries: maximumReconnectionRetries }); - }; - default_1.prototype._addPnsdkSuffix = function (name, suffix) { - this._PNSDKSuffix[name] = suffix; - }; - default_1.prototype._getPnsdkSuffix = function (separator) { - var _this = this; - return Object.keys(this._PNSDKSuffix).reduce(function (result, key) { return result + separator + _this._PNSDKSuffix[key]; }, ''); - }; - return default_1; - }()); + } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + + return this; + }; - var BASE64_CHARMAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; /** - * Decode a Base64 encoded string. + * Emit `event` with the given args. * - * @param paddedInput Base64 string with padding - * @returns ArrayBuffer with decoded data + * @param {String} event + * @param {Mixed} ... + * @return {Emitter} */ - function decode$1(paddedInput) { - // Remove up to last two equal signs. - var input = paddedInput.replace(/==?$/, ''); - var outputLength = Math.floor((input.length / 4) * 3); - // Prepare output buffer. - var data = new ArrayBuffer(outputLength); - var view = new Uint8Array(data); - var cursor = 0; - /** - * Returns the next integer representation of a sixtet of bytes from the input - * @returns sixtet of bytes - */ - function nextSixtet() { - var char = input.charAt(cursor++); - var index = BASE64_CHARMAP.indexOf(char); - if (index === -1) { - throw new Error("Illegal character at ".concat(cursor, ": ").concat(input.charAt(cursor - 1))); - } - return index; - } - for (var i = 0; i < outputLength; i += 3) { - // Obtain four sixtets - var sx1 = nextSixtet(); - var sx2 = nextSixtet(); - var sx3 = nextSixtet(); - var sx4 = nextSixtet(); - // Encode them as three octets - var oc1 = ((sx1 & 63) << 2) | (sx2 >> 4); - var oc2 = ((sx2 & 15) << 4) | (sx3 >> 2); - var oc3 = ((sx3 & 3) << 6) | (sx4 >> 0); - view[i] = oc1; - // Skip padding bytes. - if (sx3 != 64) - view[i + 1] = oc2; - if (sx4 != 64) - view[i + 2] = oc3; - } - return data; - } - /*eslint-disable */ - /* - CryptoJS v3.1.2 - code.google.com/p/crypto-js - (c) 2009-2013 by Jeff Mott. All rights reserved. - code.google.com/p/crypto-js/wiki/License - */ - var CryptoJS = CryptoJS || - (function (h, s) { - var f = {}, g = (f.lib = {}), q = function () { }, m = (g.Base = { - extend: function (a) { - q.prototype = this; - var c = new q(); - a && c.mixIn(a); - c.hasOwnProperty('init') || - (c.init = function () { - c.$super.init.apply(this, arguments); - }); - c.init.prototype = c; - c.$super = this; - return c; - }, - create: function () { - var a = this.extend(); - a.init.apply(a, arguments); - return a; - }, - init: function () { }, - mixIn: function (a) { - for (var c in a) - a.hasOwnProperty(c) && (this[c] = a[c]); - a.hasOwnProperty('toString') && (this.toString = a.toString); - }, - clone: function () { - return this.init.prototype.extend(this); - }, - }), r = (g.WordArray = m.extend({ - init: function (a, c) { - a = this.words = a || []; - this.sigBytes = c != s ? c : 4 * a.length; - }, - toString: function (a) { - return (a || k).stringify(this); - }, - concat: function (a) { - var c = this.words, d = a.words, b = this.sigBytes; - a = a.sigBytes; - this.clamp(); - if (b % 4) - for (var e = 0; e < a; e++) - c[(b + e) >>> 2] |= ((d[e >>> 2] >>> (24 - 8 * (e % 4))) & 255) << (24 - 8 * ((b + e) % 4)); - else if (65535 < d.length) - for (e = 0; e < a; e += 4) - c[(b + e) >>> 2] = d[e >>> 2]; - else - c.push.apply(c, d); - this.sigBytes += a; - return this; - }, - clamp: function () { - var a = this.words, c = this.sigBytes; - a[c >>> 2] &= 4294967295 << (32 - 8 * (c % 4)); - a.length = h.ceil(c / 4); - }, - clone: function () { - var a = m.clone.call(this); - a.words = this.words.slice(0); - return a; - }, - random: function (a) { - for (var c = [], d = 0; d < a; d += 4) - c.push((4294967296 * h.random()) | 0); - return new r.init(c, a); - }, - })), l = (f.enc = {}), k = (l.Hex = { - stringify: function (a) { - var c = a.words; - a = a.sigBytes; - for (var d = [], b = 0; b < a; b++) { - var e = (c[b >>> 2] >>> (24 - 8 * (b % 4))) & 255; - d.push((e >>> 4).toString(16)); - d.push((e & 15).toString(16)); - } - return d.join(''); - }, - parse: function (a) { - for (var c = a.length, d = [], b = 0; b < c; b += 2) - d[b >>> 3] |= parseInt(a.substr(b, 2), 16) << (24 - 4 * (b % 8)); - return new r.init(d, c / 2); - }, - }), n = (l.Latin1 = { - stringify: function (a) { - var c = a.words; - a = a.sigBytes; - for (var d = [], b = 0; b < a; b++) - d.push(String.fromCharCode((c[b >>> 2] >>> (24 - 8 * (b % 4))) & 255)); - return d.join(''); - }, - parse: function (a) { - for (var c = a.length, d = [], b = 0; b < c; b++) - d[b >>> 2] |= (a.charCodeAt(b) & 255) << (24 - 8 * (b % 4)); - return new r.init(d, c); - }, - }), j = (l.Utf8 = { - stringify: function (a) { - try { - return decodeURIComponent(escape(n.stringify(a))); - } - catch (c) { - throw Error('Malformed UTF-8 data'); - } - }, - parse: function (a) { - return n.parse(unescape(encodeURIComponent(a))); - }, - }), u = (g.BufferedBlockAlgorithm = m.extend({ - reset: function () { - this._data = new r.init(); - this._nDataBytes = 0; - }, - _append: function (a) { - 'string' == typeof a && (a = j.parse(a)); - this._data.concat(a); - this._nDataBytes += a.sigBytes; - }, - _process: function (a) { - var c = this._data, d = c.words, b = c.sigBytes, e = this.blockSize, f = b / (4 * e), f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0); - a = f * e; - b = h.min(4 * a, b); - if (a) { - for (var g = 0; g < a; g += e) - this._doProcessBlock(d, g); - g = d.splice(0, a); - c.sigBytes -= b; - } - return new r.init(g, b); - }, - clone: function () { - var a = m.clone.call(this); - a._data = this._data.clone(); - return a; - }, - _minBufferSize: 0, - })); - g.Hasher = u.extend({ - cfg: m.extend(), - init: function (a) { - this.cfg = this.cfg.extend(a); - this.reset(); - }, - reset: function () { - u.reset.call(this); - this._doReset(); - }, - update: function (a) { - this._append(a); - this._process(); - return this; - }, - finalize: function (a) { - a && this._append(a); - return this._doFinalize(); - }, - blockSize: 16, - _createHelper: function (a) { - return function (c, d) { - return new a.init(d).finalize(c); - }; - }, - _createHmacHelper: function (a) { - return function (c, d) { - return new t.HMAC.init(a, d).finalize(c); - }; - }, - }); - var t = (f.algo = {}); - return f; - })(Math); - // SHA256 - (function (h) { - for (var s = CryptoJS, f = s.lib, g = f.WordArray, q = f.Hasher, f = s.algo, m = [], r = [], l = function (a) { - return (4294967296 * (a - (a | 0))) | 0; - }, k = 2, n = 0; 64 > n;) { - var j; - a: { - j = k; - for (var u = h.sqrt(j), t = 2; t <= u; t++) - if (!(j % t)) { - j = !1; - break a; - } - j = !0; - } - j && (8 > n && (m[n] = l(h.pow(k, 0.5))), (r[n] = l(h.pow(k, 1 / 3))), n++); - k++; - } - var a = [], f = (f.SHA256 = q.extend({ - _doReset: function () { - this._hash = new g.init(m.slice(0)); - }, - _doProcessBlock: function (c, d) { - for (var b = this._hash.words, e = b[0], f = b[1], g = b[2], j = b[3], h = b[4], m = b[5], n = b[6], q = b[7], p = 0; 64 > p; p++) { - if (16 > p) - a[p] = c[d + p] | 0; - else { - var k = a[p - 15], l = a[p - 2]; - a[p] = - (((k << 25) | (k >>> 7)) ^ ((k << 14) | (k >>> 18)) ^ (k >>> 3)) + - a[p - 7] + - (((l << 15) | (l >>> 17)) ^ ((l << 13) | (l >>> 19)) ^ (l >>> 10)) + - a[p - 16]; - } - k = - q + - (((h << 26) | (h >>> 6)) ^ ((h << 21) | (h >>> 11)) ^ ((h << 7) | (h >>> 25))) + - ((h & m) ^ (~h & n)) + - r[p] + - a[p]; - l = - (((e << 30) | (e >>> 2)) ^ ((e << 19) | (e >>> 13)) ^ ((e << 10) | (e >>> 22))) + - ((e & f) ^ (e & g) ^ (f & g)); - q = n; - n = m; - m = h; - h = (j + k) | 0; - j = g; - g = f; - f = e; - e = (k + l) | 0; - } - b[0] = (b[0] + e) | 0; - b[1] = (b[1] + f) | 0; - b[2] = (b[2] + g) | 0; - b[3] = (b[3] + j) | 0; - b[4] = (b[4] + h) | 0; - b[5] = (b[5] + m) | 0; - b[6] = (b[6] + n) | 0; - b[7] = (b[7] + q) | 0; - }, - _doFinalize: function () { - var a = this._data, d = a.words, b = 8 * this._nDataBytes, e = 8 * a.sigBytes; - d[e >>> 5] |= 128 << (24 - (e % 32)); - d[(((e + 64) >>> 9) << 4) + 14] = h.floor(b / 4294967296); - d[(((e + 64) >>> 9) << 4) + 15] = b; - a.sigBytes = 4 * d.length; - this._process(); - return this._hash; - }, - clone: function () { - var a = q.clone.call(this); - a._hash = this._hash.clone(); - return a; - }, - })); - s.SHA256 = q._createHelper(f); - s.HmacSHA256 = q._createHmacHelper(f); - })(Math); - // HMAC SHA256 - (function () { - var h = CryptoJS, s = h.enc.Utf8; - h.algo.HMAC = h.lib.Base.extend({ - init: function (f, g) { - f = this._hasher = new f.init(); - 'string' == typeof g && (g = s.parse(g)); - var h = f.blockSize, m = 4 * h; - g.sigBytes > m && (g = f.finalize(g)); - g.clamp(); - for (var r = (this._oKey = g.clone()), l = (this._iKey = g.clone()), k = r.words, n = l.words, j = 0; j < h; j++) - (k[j] ^= 1549556828), (n[j] ^= 909522486); - r.sigBytes = l.sigBytes = m; - this.reset(); - }, - reset: function () { - var f = this._hasher; - f.reset(); - f.update(this._iKey); - }, - update: function (f) { - this._hasher.update(f); - return this; - }, - finalize: function (f) { - var g = this._hasher; - f = g.finalize(f); - g.reset(); - return g.finalize(this._oKey.clone().concat(f)); - }, - }); - })(); - // Base64 - (function () { - var u = CryptoJS, p = u.lib.WordArray; - u.enc.Base64 = { - stringify: function (d) { - var l = d.words, p = d.sigBytes, t = this._map; - d.clamp(); - d = []; - for (var r = 0; r < p; r += 3) - for (var w = (((l[r >>> 2] >>> (24 - 8 * (r % 4))) & 255) << 16) | - (((l[(r + 1) >>> 2] >>> (24 - 8 * ((r + 1) % 4))) & 255) << 8) | - ((l[(r + 2) >>> 2] >>> (24 - 8 * ((r + 2) % 4))) & 255), v = 0; 4 > v && r + 0.75 * v < p; v++) - d.push(t.charAt((w >>> (6 * (3 - v))) & 63)); - if ((l = t.charAt(64))) - for (; d.length % 4;) - d.push(l); - return d.join(''); - }, - parse: function (d) { - var l = d.length, s = this._map, t = s.charAt(64); - t && ((t = d.indexOf(t)), -1 != t && (l = t)); - for (var t = [], r = 0, w = 0; w < l; w++) - if (w % 4) { - var v = s.indexOf(d.charAt(w - 1)) << (2 * (w % 4)), b = s.indexOf(d.charAt(w)) >>> (6 - 2 * (w % 4)); - t[r >>> 2] |= (v | b) << (24 - 8 * (r % 4)); - r++; - } - return p.create(t, r); - }, - _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', - }; - })(); - // BlockCipher - (function (u) { - function p(b, n, a, c, e, j, k) { - b = b + ((n & a) | (~n & c)) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - function d(b, n, a, c, e, j, k) { - b = b + ((n & c) | (a & ~c)) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - function l(b, n, a, c, e, j, k) { - b = b + (n ^ a ^ c) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - function s(b, n, a, c, e, j, k) { - b = b + (a ^ (n | ~c)) + e + k; - return ((b << j) | (b >>> (32 - j))) + n; - } - for (var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) - b[x] = (4294967296 * u.abs(u.sin(x + 1))) | 0; - r = r.MD5 = v.extend({ - _doReset: function () { - this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878]); - }, - _doProcessBlock: function (q, n) { - for (var a = 0; 16 > a; a++) { - var c = n + a, e = q[c]; - q[c] = (((e << 8) | (e >>> 24)) & 16711935) | (((e << 24) | (e >>> 8)) & 4278255360); - } - var a = this._hash.words, c = q[n + 0], e = q[n + 1], j = q[n + 2], k = q[n + 3], z = q[n + 4], r = q[n + 5], t = q[n + 6], w = q[n + 7], v = q[n + 8], A = q[n + 9], B = q[n + 10], C = q[n + 11], u = q[n + 12], D = q[n + 13], E = q[n + 14], x = q[n + 15], f = a[0], m = a[1], g = a[2], h = a[3], f = p(f, m, g, h, c, 7, b[0]), h = p(h, f, m, g, e, 12, b[1]), g = p(g, h, f, m, j, 17, b[2]), m = p(m, g, h, f, k, 22, b[3]), f = p(f, m, g, h, z, 7, b[4]), h = p(h, f, m, g, r, 12, b[5]), g = p(g, h, f, m, t, 17, b[6]), m = p(m, g, h, f, w, 22, b[7]), f = p(f, m, g, h, v, 7, b[8]), h = p(h, f, m, g, A, 12, b[9]), g = p(g, h, f, m, B, 17, b[10]), m = p(m, g, h, f, C, 22, b[11]), f = p(f, m, g, h, u, 7, b[12]), h = p(h, f, m, g, D, 12, b[13]), g = p(g, h, f, m, E, 17, b[14]), m = p(m, g, h, f, x, 22, b[15]), f = d(f, m, g, h, e, 5, b[16]), h = d(h, f, m, g, t, 9, b[17]), g = d(g, h, f, m, C, 14, b[18]), m = d(m, g, h, f, c, 20, b[19]), f = d(f, m, g, h, r, 5, b[20]), h = d(h, f, m, g, B, 9, b[21]), g = d(g, h, f, m, x, 14, b[22]), m = d(m, g, h, f, z, 20, b[23]), f = d(f, m, g, h, A, 5, b[24]), h = d(h, f, m, g, E, 9, b[25]), g = d(g, h, f, m, k, 14, b[26]), m = d(m, g, h, f, v, 20, b[27]), f = d(f, m, g, h, D, 5, b[28]), h = d(h, f, m, g, j, 9, b[29]), g = d(g, h, f, m, w, 14, b[30]), m = d(m, g, h, f, u, 20, b[31]), f = l(f, m, g, h, r, 4, b[32]), h = l(h, f, m, g, v, 11, b[33]), g = l(g, h, f, m, C, 16, b[34]), m = l(m, g, h, f, E, 23, b[35]), f = l(f, m, g, h, e, 4, b[36]), h = l(h, f, m, g, z, 11, b[37]), g = l(g, h, f, m, w, 16, b[38]), m = l(m, g, h, f, B, 23, b[39]), f = l(f, m, g, h, D, 4, b[40]), h = l(h, f, m, g, c, 11, b[41]), g = l(g, h, f, m, k, 16, b[42]), m = l(m, g, h, f, t, 23, b[43]), f = l(f, m, g, h, A, 4, b[44]), h = l(h, f, m, g, u, 11, b[45]), g = l(g, h, f, m, x, 16, b[46]), m = l(m, g, h, f, j, 23, b[47]), f = s(f, m, g, h, c, 6, b[48]), h = s(h, f, m, g, w, 10, b[49]), g = s(g, h, f, m, E, 15, b[50]), m = s(m, g, h, f, r, 21, b[51]), f = s(f, m, g, h, u, 6, b[52]), h = s(h, f, m, g, k, 10, b[53]), g = s(g, h, f, m, B, 15, b[54]), m = s(m, g, h, f, e, 21, b[55]), f = s(f, m, g, h, v, 6, b[56]), h = s(h, f, m, g, x, 10, b[57]), g = s(g, h, f, m, t, 15, b[58]), m = s(m, g, h, f, D, 21, b[59]), f = s(f, m, g, h, z, 6, b[60]), h = s(h, f, m, g, C, 10, b[61]), g = s(g, h, f, m, j, 15, b[62]), m = s(m, g, h, f, A, 21, b[63]); - a[0] = (a[0] + f) | 0; - a[1] = (a[1] + m) | 0; - a[2] = (a[2] + g) | 0; - a[3] = (a[3] + h) | 0; - }, - _doFinalize: function () { - var b = this._data, n = b.words, a = 8 * this._nDataBytes, c = 8 * b.sigBytes; - n[c >>> 5] |= 128 << (24 - (c % 32)); - var e = u.floor(a / 4294967296); - n[(((c + 64) >>> 9) << 4) + 15] = (((e << 8) | (e >>> 24)) & 16711935) | (((e << 24) | (e >>> 8)) & 4278255360); - n[(((c + 64) >>> 9) << 4) + 14] = (((a << 8) | (a >>> 24)) & 16711935) | (((a << 24) | (a >>> 8)) & 4278255360); - b.sigBytes = 4 * (n.length + 1); - this._process(); - b = this._hash; - n = b.words; - for (a = 0; 4 > a; a++) - (c = n[a]), (n[a] = (((c << 8) | (c >>> 24)) & 16711935) | (((c << 24) | (c >>> 8)) & 4278255360)); - return b; - }, - clone: function () { - var b = v.clone.call(this); - b._hash = this._hash.clone(); - return b; - }, - }); - t.MD5 = v._createHelper(r); - t.HmacMD5 = v._createHmacHelper(r); - })(Math); - (function () { - var u = CryptoJS, p = u.lib, d = p.Base, l = p.WordArray, p = u.algo, s = (p.EvpKDF = d.extend({ - cfg: d.extend({ keySize: 4, hasher: p.MD5, iterations: 1 }), - init: function (d) { - this.cfg = this.cfg.extend(d); - }, - compute: function (d, r) { - for (var p = this.cfg, s = p.hasher.create(), b = l.create(), u = b.words, q = p.keySize, p = p.iterations; u.length < q;) { - n && s.update(n); - var n = s.update(d).finalize(r); - s.reset(); - for (var a = 1; a < p; a++) - (n = s.finalize(n)), s.reset(); - b.concat(n); - } - b.sigBytes = 4 * q; - return b; - }, - })); - u.EvpKDF = function (d, l, p) { - return s.create(p).compute(d, l); - }; - })(); - // Cipher - CryptoJS.lib.Cipher || - (function (u) { - var p = CryptoJS, d = p.lib, l = d.Base, s = d.WordArray, t = d.BufferedBlockAlgorithm, r = p.enc.Base64, w = p.algo.EvpKDF, v = (d.Cipher = t.extend({ - cfg: l.extend(), - createEncryptor: function (e, a) { - return this.create(this._ENC_XFORM_MODE, e, a); - }, - createDecryptor: function (e, a) { - return this.create(this._DEC_XFORM_MODE, e, a); - }, - init: function (e, a, b) { - this.cfg = this.cfg.extend(b); - this._xformMode = e; - this._key = a; - this.reset(); - }, - reset: function () { - t.reset.call(this); - this._doReset(); - }, - process: function (e) { - this._append(e); - return this._process(); - }, - finalize: function (e) { - e && this._append(e); - return this._doFinalize(); - }, - keySize: 4, - ivSize: 4, - _ENC_XFORM_MODE: 1, - _DEC_XFORM_MODE: 2, - _createHelper: function (e) { - return { - encrypt: function (b, k, d) { - return ('string' == typeof k ? c : a).encrypt(e, b, k, d); - }, - decrypt: function (b, k, d) { - return ('string' == typeof k ? c : a).decrypt(e, b, k, d); - }, - }; - }, - })); - d.StreamCipher = v.extend({ - _doFinalize: function () { - return this._process(!0); - }, - blockSize: 1, - }); - var b = (p.mode = {}), x = function (e, a, b) { - var c = this._iv; - c ? (this._iv = u) : (c = this._prevBlock); - for (var d = 0; d < b; d++) - e[a + d] ^= c[d]; - }, q = (d.BlockCipherMode = l.extend({ - createEncryptor: function (e, a) { - return this.Encryptor.create(e, a); - }, - createDecryptor: function (e, a) { - return this.Decryptor.create(e, a); - }, - init: function (e, a) { - this._cipher = e; - this._iv = a; - }, - })).extend(); - q.Encryptor = q.extend({ - processBlock: function (e, a) { - var b = this._cipher, c = b.blockSize; - x.call(this, e, a, c); - b.encryptBlock(e, a); - this._prevBlock = e.slice(a, a + c); - }, - }); - q.Decryptor = q.extend({ - processBlock: function (e, a) { - var b = this._cipher, c = b.blockSize, d = e.slice(a, a + c); - b.decryptBlock(e, a); - x.call(this, e, a, c); - this._prevBlock = d; - }, - }); - b = b.CBC = q; - q = (p.pad = {}).Pkcs7 = { - pad: function (a, b) { - for (var c = 4 * b, c = c - (a.sigBytes % c), d = (c << 24) | (c << 16) | (c << 8) | c, l = [], n = 0; n < c; n += 4) - l.push(d); - c = s.create(l, c); - a.concat(c); - }, - unpad: function (a) { - a.sigBytes -= a.words[(a.sigBytes - 1) >>> 2] & 255; - }, - }; - d.BlockCipher = v.extend({ - cfg: v.cfg.extend({ mode: b, padding: q }), - reset: function () { - v.reset.call(this); - var a = this.cfg, b = a.iv, a = a.mode; - if (this._xformMode == this._ENC_XFORM_MODE) - var c = a.createEncryptor; - else - (c = a.createDecryptor), (this._minBufferSize = 1); - this._mode = c.call(a, this, b && b.words); - }, - _doProcessBlock: function (a, b) { - this._mode.processBlock(a, b); - }, - _doFinalize: function () { - var a = this.cfg.padding; - if (this._xformMode == this._ENC_XFORM_MODE) { - a.pad(this._data, this.blockSize); - var b = this._process(!0); - } - else - (b = this._process(!0)), a.unpad(b); - return b; - }, - blockSize: 4, - }); - var n = (d.CipherParams = l.extend({ - init: function (a) { - this.mixIn(a); - }, - toString: function (a) { - return (a || this.formatter).stringify(this); - }, - })), b = ((p.format = {}).OpenSSL = { - stringify: function (a) { - var b = a.ciphertext; - a = a.salt; - return (a ? s.create([1398893684, 1701076831]).concat(a).concat(b) : b).toString(r); - }, - parse: function (a) { - a = r.parse(a); - var b = a.words; - if (1398893684 == b[0] && 1701076831 == b[1]) { - var c = s.create(b.slice(2, 4)); - b.splice(0, 4); - a.sigBytes -= 16; - } - return n.create({ ciphertext: a, salt: c }); - }, - }), a = (d.SerializableCipher = l.extend({ - cfg: l.extend({ format: b }), - encrypt: function (a, b, c, d) { - d = this.cfg.extend(d); - var l = a.createEncryptor(c, d); - b = l.finalize(b); - l = l.cfg; - return n.create({ - ciphertext: b, - key: c, - iv: l.iv, - algorithm: a, - mode: l.mode, - padding: l.padding, - blockSize: a.blockSize, - formatter: d.format, - }); - }, - decrypt: function (a, b, c, d) { - d = this.cfg.extend(d); - b = this._parse(b, d.format); - return a.createDecryptor(c, d).finalize(b.ciphertext); - }, - _parse: function (a, b) { - return 'string' == typeof a ? b.parse(a, this) : a; - }, - })), p = ((p.kdf = {}).OpenSSL = { - execute: function (a, b, c, d) { - d || (d = s.random(8)); - a = w.create({ keySize: b + c }).compute(a, d); - c = s.create(a.words.slice(b), 4 * c); - a.sigBytes = 4 * b; - return n.create({ key: a, iv: c, salt: d }); - }, - }), c = (d.PasswordBasedCipher = a.extend({ - cfg: a.cfg.extend({ kdf: p }), - encrypt: function (b, c, d, l) { - l = this.cfg.extend(l); - d = l.kdf.execute(d, b.keySize, b.ivSize); - l.iv = d.iv; - b = a.encrypt.call(this, b, c, d.key, l); - b.mixIn(d); - return b; - }, - decrypt: function (b, c, d, l) { - l = this.cfg.extend(l); - c = this._parse(c, l.format); - d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt); - l.iv = d.iv; - return a.decrypt.call(this, b, c, d.key, l); - }, - })); - })(); - // AES - (function () { - for (var u = CryptoJS, p = u.lib.BlockCipher, d = u.algo, l = [], s = [], t = [], r = [], w = [], v = [], b = [], x = [], q = [], n = [], a = [], c = 0; 256 > c; c++) - a[c] = 128 > c ? c << 1 : (c << 1) ^ 283; - for (var e = 0, j = 0, c = 0; 256 > c; c++) { - var k = j ^ (j << 1) ^ (j << 2) ^ (j << 3) ^ (j << 4), k = (k >>> 8) ^ (k & 255) ^ 99; - l[e] = k; - s[k] = e; - var z = a[e], F = a[z], G = a[F], y = (257 * a[k]) ^ (16843008 * k); - t[e] = (y << 24) | (y >>> 8); - r[e] = (y << 16) | (y >>> 16); - w[e] = (y << 8) | (y >>> 24); - v[e] = y; - y = (16843009 * G) ^ (65537 * F) ^ (257 * z) ^ (16843008 * e); - b[k] = (y << 24) | (y >>> 8); - x[k] = (y << 16) | (y >>> 16); - q[k] = (y << 8) | (y >>> 24); - n[k] = y; - e ? ((e = z ^ a[a[a[G ^ z]]]), (j ^= a[a[j]])) : (e = j = 1); - } - var H = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], d = (d.AES = p.extend({ - _doReset: function () { - for (var a = this._key, c = a.words, d = a.sigBytes / 4, a = 4 * ((this._nRounds = d + 6) + 1), e = (this._keySchedule = []), j = 0; j < a; j++) - if (j < d) - e[j] = c[j]; - else { - var k = e[j - 1]; - j % d - ? 6 < d && - 4 == j % d && - (k = (l[k >>> 24] << 24) | (l[(k >>> 16) & 255] << 16) | (l[(k >>> 8) & 255] << 8) | l[k & 255]) - : ((k = (k << 8) | (k >>> 24)), - (k = (l[k >>> 24] << 24) | (l[(k >>> 16) & 255] << 16) | (l[(k >>> 8) & 255] << 8) | l[k & 255]), - (k ^= H[(j / d) | 0] << 24)); - e[j] = e[j - d] ^ k; - } - c = this._invKeySchedule = []; - for (d = 0; d < a; d++) - (j = a - d), - (k = d % 4 ? e[j] : e[j - 4]), - (c[d] = - 4 > d || 4 >= j ? k : b[l[k >>> 24]] ^ x[l[(k >>> 16) & 255]] ^ q[l[(k >>> 8) & 255]] ^ n[l[k & 255]]); - }, - encryptBlock: function (a, b) { - this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l); - }, - decryptBlock: function (a, c) { - var d = a[c + 1]; - a[c + 1] = a[c + 3]; - a[c + 3] = d; - this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s); - d = a[c + 1]; - a[c + 1] = a[c + 3]; - a[c + 3] = d; - }, - _doCryptBlock: function (a, b, c, d, e, j, l, f) { - for (var m = this._nRounds, g = a[b] ^ c[0], h = a[b + 1] ^ c[1], k = a[b + 2] ^ c[2], n = a[b + 3] ^ c[3], p = 4, r = 1; r < m; r++) - var q = d[g >>> 24] ^ e[(h >>> 16) & 255] ^ j[(k >>> 8) & 255] ^ l[n & 255] ^ c[p++], s = d[h >>> 24] ^ e[(k >>> 16) & 255] ^ j[(n >>> 8) & 255] ^ l[g & 255] ^ c[p++], t = d[k >>> 24] ^ e[(n >>> 16) & 255] ^ j[(g >>> 8) & 255] ^ l[h & 255] ^ c[p++], n = d[n >>> 24] ^ e[(g >>> 16) & 255] ^ j[(h >>> 8) & 255] ^ l[k & 255] ^ c[p++], g = q, h = s, k = t; - q = ((f[g >>> 24] << 24) | (f[(h >>> 16) & 255] << 16) | (f[(k >>> 8) & 255] << 8) | f[n & 255]) ^ c[p++]; - s = ((f[h >>> 24] << 24) | (f[(k >>> 16) & 255] << 16) | (f[(n >>> 8) & 255] << 8) | f[g & 255]) ^ c[p++]; - t = ((f[k >>> 24] << 24) | (f[(n >>> 16) & 255] << 16) | (f[(g >>> 8) & 255] << 8) | f[h & 255]) ^ c[p++]; - n = ((f[n >>> 24] << 24) | (f[(g >>> 16) & 255] << 16) | (f[(h >>> 8) & 255] << 8) | f[k & 255]) ^ c[p++]; - a[b] = q; - a[b + 1] = s; - a[b + 2] = t; - a[b + 3] = n; - }, - keySize: 8, - })); - u.AES = p._createHelper(d); - })(); - // Mode ECB - CryptoJS.mode.ECB = (function () { - var ECB = CryptoJS.lib.BlockCipherMode.extend(); - ECB.Encryptor = ECB.extend({ - processBlock: function (words, offset) { - this._cipher.encryptBlock(words, offset); - }, - }); - ECB.Decryptor = ECB.extend({ - processBlock: function (words, offset) { - this._cipher.decryptBlock(words, offset); - }, - }); - return ECB; - })(); - var hmacSha256 = CryptoJS; + Emitter.prototype.emit = function(event){ + this._callbacks = this._callbacks || {}; - function bufferToWordArray(b) { - var wa = []; - var i; - for (i = 0; i < b.length; i += 1) { - wa[(i / 4) | 0] |= b[i] << (24 - 8 * i); - } - return hmacSha256.lib.WordArray.create(wa, b.length); - } - var default_1$a = /** @class */ (function () { - function default_1(_a) { - var config = _a.config; - this._config = config; - this._iv = '0123456789012345'; - this._allowedKeyEncodings = ['hex', 'utf8', 'base64', 'binary']; - this._allowedKeyLengths = [128, 256]; - this._allowedModes = ['ecb', 'cbc']; - this._defaultOptions = { - encryptKey: true, - keyEncoding: 'utf8', - keyLength: 256, - mode: 'cbc', - }; - } - default_1.prototype.HMACSHA256 = function (data) { - var hash = hmacSha256.HmacSHA256(data, this._config.secretKey); - return hash.toString(hmacSha256.enc.Base64); - }; - default_1.prototype.SHA256 = function (s) { - return hmacSha256.SHA256(s).toString(hmacSha256.enc.Hex); - }; - default_1.prototype._parseOptions = function (incomingOptions) { - // Defaults - var options = incomingOptions || {}; - if (!options.hasOwnProperty('encryptKey')) - options.encryptKey = this._defaultOptions.encryptKey; - if (!options.hasOwnProperty('keyEncoding')) - options.keyEncoding = this._defaultOptions.keyEncoding; - if (!options.hasOwnProperty('keyLength')) - options.keyLength = this._defaultOptions.keyLength; - if (!options.hasOwnProperty('mode')) - options.mode = this._defaultOptions.mode; - // Validation - if (this._allowedKeyEncodings.indexOf(options.keyEncoding.toLowerCase()) === -1) { - options.keyEncoding = this._defaultOptions.keyEncoding; - } - if (this._allowedKeyLengths.indexOf(parseInt(options.keyLength, 10)) === -1) { - options.keyLength = this._defaultOptions.keyLength; - } - if (this._allowedModes.indexOf(options.mode.toLowerCase()) === -1) { - options.mode = this._defaultOptions.mode; - } - return options; - }; - default_1.prototype._decodeKey = function (key, options) { - if (options.keyEncoding === 'base64') { - return hmacSha256.enc.Base64.parse(key); - } - if (options.keyEncoding === 'hex') { - return hmacSha256.enc.Hex.parse(key); - } - return key; - }; - default_1.prototype._getPaddedKey = function (key, options) { - key = this._decodeKey(key, options); - if (options.encryptKey) { - return hmacSha256.enc.Utf8.parse(this.SHA256(key).slice(0, 32)); - } - return key; - }; - default_1.prototype._getMode = function (options) { - if (options.mode === 'ecb') { - return hmacSha256.mode.ECB; - } - return hmacSha256.mode.CBC; - }; - default_1.prototype._getIV = function (options) { - return options.mode === 'cbc' ? hmacSha256.enc.Utf8.parse(this._iv) : null; - }; - default_1.prototype._getRandomIV = function () { - return hmacSha256.lib.WordArray.random(16); - }; - default_1.prototype.encrypt = function (data, customCipherKey, options) { - if (this._config.customEncrypt) { - return this._config.customEncrypt(data); - } - return this.pnEncrypt(data, customCipherKey, options); - }; - default_1.prototype.decrypt = function (data, customCipherKey, options) { - if (this._config.customDecrypt) { - return this._config.customDecrypt(data); - } - return this.pnDecrypt(data, customCipherKey, options); - }; - default_1.prototype.pnEncrypt = function (data, customCipherKey, options) { - if (!customCipherKey && !this._config.cipherKey) - return data; - options = this._parseOptions(options); - var mode = this._getMode(options); - var cipherKey = this._getPaddedKey(customCipherKey || this._config.cipherKey, options); - if (this._config.useRandomIVs) { - var waIv = this._getRandomIV(); - var waPayload = hmacSha256.AES.encrypt(data, cipherKey, { iv: waIv, mode: mode }).ciphertext; - return waIv.clone().concat(waPayload.clone()).toString(hmacSha256.enc.Base64); - } - var iv = this._getIV(options); - var encryptedHexArray = hmacSha256.AES.encrypt(data, cipherKey, { iv: iv, mode: mode }).ciphertext; - var base64Encrypted = encryptedHexArray.toString(hmacSha256.enc.Base64); - return base64Encrypted || data; - }; - default_1.prototype.pnDecrypt = function (data, customCipherKey, options) { - if (!customCipherKey && !this._config.cipherKey) - return data; - options = this._parseOptions(options); - var mode = this._getMode(options); - var cipherKey = this._getPaddedKey(customCipherKey || this._config.cipherKey, options); - if (this._config.useRandomIVs) { - var ciphertext = new Uint8ClampedArray(decode$1(data)); - var iv = bufferToWordArray(ciphertext.slice(0, 16)); - var payload = bufferToWordArray(ciphertext.slice(16)); - try { - var plainJSON = hmacSha256.AES.decrypt({ ciphertext: payload }, cipherKey, { iv: iv, mode: mode }).toString(hmacSha256.enc.Utf8); - var plaintext = JSON.parse(plainJSON); - return plaintext; - } - catch (e) { - return null; - } - } - else { - var iv = this._getIV(options); - try { - var ciphertext = hmacSha256.enc.Base64.parse(data); - var plainJSON = hmacSha256.AES.decrypt({ ciphertext: ciphertext }, cipherKey, { iv: iv, mode: mode }).toString(hmacSha256.enc.Utf8); - var plaintext = JSON.parse(plainJSON); - return plaintext; - } - catch (e) { - return null; - } - } - }; - return default_1; - }()); + var args = new Array(arguments.length - 1) + , callbacks = this._callbacks['$' + event]; - var default_1$9 = /** @class */ (function () { - function default_1(_a) { - var timeEndpoint = _a.timeEndpoint; - this._timeEndpoint = timeEndpoint; - } - default_1.prototype.onReconnection = function (reconnectionCallback) { - this._reconnectionCallback = reconnectionCallback; - }; - default_1.prototype.startPolling = function () { - this._timeTimer = setInterval(this._performTimeLoop.bind(this), 3000); - }; - default_1.prototype.stopPolling = function () { - clearInterval(this._timeTimer); - }; - default_1.prototype._performTimeLoop = function () { - var _this = this; - this._timeEndpoint(function (status) { - if (!status.error) { - clearInterval(_this._timeTimer); - _this._reconnectionCallback(); - } - }); - }; - return default_1; - }()); + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } - /* */ - var hashCode = function (payload) { - var hash = 0; - if (payload.length === 0) - return hash; - for (var i = 0; i < payload.length; i += 1) { - var character = payload.charCodeAt(i); - hash = (hash << 5) - hash + character; // eslint-disable-line - hash = hash & hash; // eslint-disable-line - } - return hash; - }; - var default_1$8 = /** @class */ (function () { - function default_1(_a) { - var config = _a.config; - this.hashHistory = []; - this._config = config; + if (callbacks) { + callbacks = callbacks.slice(0); + for (var i = 0, len = callbacks.length; i < len; ++i) { + callbacks[i].apply(this, args); } - default_1.prototype.getKey = function (message) { - var hashedPayload = hashCode(JSON.stringify(message.payload)).toString(); - var timetoken = message.publishMetaData.publishTimetoken; - return "".concat(timetoken, "-").concat(hashedPayload); - }; - default_1.prototype.isDuplicate = function (message) { - return this.hashHistory.includes(this.getKey(message)); - }; - default_1.prototype.addEntry = function (message) { - if (this.hashHistory.length >= this._config.maximumCacheSize) { - this.hashHistory.shift(); - } - this.hashHistory.push(this.getKey(message)); - }; - default_1.prototype.clearHistory = function () { - this.hashHistory = []; - }; - return default_1; - }()); + } - function objectToList(o) { - var l = []; - Object.keys(o).forEach(function (key) { return l.push(key); }); - return l; - } - function encodeString(input) { - return encodeURIComponent(input).replace(/[!~*'()]/g, function (x) { return "%".concat(x.charCodeAt(0).toString(16).toUpperCase()); }); - } - function objectToListSorted(o) { - return objectToList(o).sort(); - } - function signPamFromParams(params) { - var l = objectToListSorted(params); - return l.map(function (paramKey) { return "".concat(paramKey, "=").concat(encodeString(params[paramKey])); }).join('&'); - } - function endsWith(searchString, suffix) { - return searchString.indexOf(suffix, this.length - suffix.length) !== -1; - } - function createPromise() { - var successResolve; - var failureResolve; - var promise = new Promise(function (fulfill, reject) { - successResolve = fulfill; - failureResolve = reject; - }); - return { promise: promise, reject: failureResolve, fulfill: successResolve }; - } - var utils$5 = { - signPamFromParams: signPamFromParams, - endsWith: endsWith, - createPromise: createPromise, - encodeString: encodeString, + return this; }; - /* */ - var categories = { - // SDK will announce when the network appears to be connected again. - PNNetworkUpCategory: 'PNNetworkUpCategory', - // SDK will announce when the network appears to down. - PNNetworkDownCategory: 'PNNetworkDownCategory', - // call failed when network was unable to complete the call. - PNNetworkIssuesCategory: 'PNNetworkIssuesCategory', - // network call timed out - PNTimeoutCategory: 'PNTimeoutCategory', - // server responded with bad response - PNBadRequestCategory: 'PNBadRequestCategory', - // server responded with access denied - PNAccessDeniedCategory: 'PNAccessDeniedCategory', - // something strange happened; please check the logs. - PNUnknownCategory: 'PNUnknownCategory', - // on reconnection - PNReconnectedCategory: 'PNReconnectedCategory', - PNConnectedCategory: 'PNConnectedCategory', - PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', - PNDisconnectedCategory: 'PNDisconnectedCategory', - }; + /** + * Return array of callbacks for `event`. + * + * @param {String} event + * @return {Array} + * @api public + */ - var default_1$7 = /** @class */ (function () { - function default_1(_a) { - var subscribeEndpoint = _a.subscribeEndpoint, leaveEndpoint = _a.leaveEndpoint, heartbeatEndpoint = _a.heartbeatEndpoint, setStateEndpoint = _a.setStateEndpoint, timeEndpoint = _a.timeEndpoint, getFileUrl = _a.getFileUrl, config = _a.config, crypto = _a.crypto, listenerManager = _a.listenerManager; - this._listenerManager = listenerManager; - this._config = config; - this._leaveEndpoint = leaveEndpoint; - this._heartbeatEndpoint = heartbeatEndpoint; - this._setStateEndpoint = setStateEndpoint; - this._subscribeEndpoint = subscribeEndpoint; - this._getFileUrl = getFileUrl; - this._crypto = crypto; - this._channels = {}; - this._presenceChannels = {}; - this._heartbeatChannels = {}; - this._heartbeatChannelGroups = {}; - this._channelGroups = {}; - this._presenceChannelGroups = {}; - this._pendingChannelSubscriptions = []; - this._pendingChannelGroupSubscriptions = []; - this._currentTimetoken = 0; - this._lastTimetoken = 0; - this._storedTimetoken = null; - this._subscriptionStatusAnnounced = false; - this._isOnline = true; - this._reconnectionManager = new default_1$9({ timeEndpoint: timeEndpoint }); - this._dedupingManager = new default_1$8({ config: config }); - } - default_1.prototype.adaptStateChange = function (args, callback) { - var _this = this; - var state = args.state, _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = args.withHeartbeat, withHeartbeat = _c === void 0 ? false : _c; - channels.forEach(function (channel) { - if (channel in _this._channels) - _this._channels[channel].state = state; - }); - channelGroups.forEach(function (channelGroup) { - if (channelGroup in _this._channelGroups) { - _this._channelGroups[channelGroup].state = state; - } - }); - if (withHeartbeat) { - var presenceState_1 = {}; - channels.forEach(function (channel) { return (presenceState_1[channel] = state); }); - channelGroups.forEach(function (group) { return (presenceState_1[group] = state); }); - return this._heartbeatEndpoint({ channels: channels, channelGroups: channelGroups, state: presenceState_1 }, callback); - } - return this._setStateEndpoint({ state: state, channels: channels, channelGroups: channelGroups }, callback); - }; - default_1.prototype.adaptPresenceChange = function (args) { - var _this = this; - var connected = args.connected, _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b; - if (connected) { - channels.forEach(function (channel) { - _this._heartbeatChannels[channel] = { state: {} }; - }); - channelGroups.forEach(function (channelGroup) { - _this._heartbeatChannelGroups[channelGroup] = { state: {} }; - }); - } - else { - channels.forEach(function (channel) { - if (channel in _this._heartbeatChannels) { - delete _this._heartbeatChannels[channel]; - } - }); - channelGroups.forEach(function (channelGroup) { - if (channelGroup in _this._heartbeatChannelGroups) { - delete _this._heartbeatChannelGroups[channelGroup]; - } - }); - if (this._config.suppressLeaveEvents === false) { - this._leaveEndpoint({ channels: channels, channelGroups: channelGroups }, function (status) { - _this._listenerManager.announceStatus(status); - }); - } - } - this.reconnect(); - }; - default_1.prototype.adaptSubscribeChange = function (args) { - var _this = this; - var timetoken = args.timetoken, _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = args.withPresence, withPresence = _c === void 0 ? false : _c, _d = args.withHeartbeats, withHeartbeats = _d === void 0 ? false : _d; - if (!this._config.subscribeKey || this._config.subscribeKey === '') { - // eslint-disable-next-line - if (console && console.log) { - console.log('subscribe key missing; aborting subscribe'); //eslint-disable-line - } - return; - } - if (timetoken) { - this._lastTimetoken = this._currentTimetoken; - this._currentTimetoken = timetoken; - } - // reset the current timetoken to get a connect event. - // $FlowFixMe - if (this._currentTimetoken !== '0' && this._currentTimetoken !== 0) { - this._storedTimetoken = this._currentTimetoken; - this._currentTimetoken = 0; - } - channels.forEach(function (channel) { - _this._channels[channel] = { state: {} }; - if (withPresence) - _this._presenceChannels[channel] = {}; - if (withHeartbeats || _this._config.getHeartbeatInterval()) - _this._heartbeatChannels[channel] = {}; - _this._pendingChannelSubscriptions.push(channel); - }); - channelGroups.forEach(function (channelGroup) { - _this._channelGroups[channelGroup] = { state: {} }; - if (withPresence) - _this._presenceChannelGroups[channelGroup] = {}; - if (withHeartbeats || _this._config.getHeartbeatInterval()) - _this._heartbeatChannelGroups[channelGroup] = {}; - _this._pendingChannelGroupSubscriptions.push(channelGroup); - }); - this._subscriptionStatusAnnounced = false; - this.reconnect(); - }; - default_1.prototype.adaptUnsubscribeChange = function (args, isOffline) { - var _this = this; - var _a = args.channels, channels = _a === void 0 ? [] : _a, _b = args.channelGroups, channelGroups = _b === void 0 ? [] : _b; - // keep track of which channels and channel groups - // we are going to unsubscribe from. - var actualChannels = []; - var actualChannelGroups = []; - // - channels.forEach(function (channel) { - if (channel in _this._channels) { - delete _this._channels[channel]; - actualChannels.push(channel); - if (channel in _this._heartbeatChannels) { - delete _this._heartbeatChannels[channel]; - } - } - if (channel in _this._presenceChannels) { - delete _this._presenceChannels[channel]; - actualChannels.push(channel); - } - }); - channelGroups.forEach(function (channelGroup) { - if (channelGroup in _this._channelGroups) { - delete _this._channelGroups[channelGroup]; - actualChannelGroups.push(channelGroup); - if (channelGroup in _this._heartbeatChannelGroups) { - delete _this._heartbeatChannelGroups[channelGroup]; - } - } - if (channelGroup in _this._presenceChannelGroups) { - delete _this._presenceChannelGroups[channelGroup]; - actualChannelGroups.push(channelGroup); - } - }); - // no-op if there are no channels and cg's to unsubscribe from. - if (actualChannels.length === 0 && actualChannelGroups.length === 0) { - return; - } - if (this._config.suppressLeaveEvents === false && !isOffline) { - this._leaveEndpoint({ channels: actualChannels, channelGroups: actualChannelGroups }, function (status) { - status.affectedChannels = actualChannels; - status.affectedChannelGroups = actualChannelGroups; - status.currentTimetoken = _this._currentTimetoken; - status.lastTimetoken = _this._lastTimetoken; - _this._listenerManager.announceStatus(status); - }); - } - // if we have nothing to subscribe to, reset the timetoken. - if (Object.keys(this._channels).length === 0 && - Object.keys(this._presenceChannels).length === 0 && - Object.keys(this._channelGroups).length === 0 && - Object.keys(this._presenceChannelGroups).length === 0) { - this._lastTimetoken = 0; - this._currentTimetoken = 0; - this._storedTimetoken = null; - this._region = null; - this._reconnectionManager.stopPolling(); - } - this.reconnect(); - }; - default_1.prototype.unsubscribeAll = function (isOffline) { - this.adaptUnsubscribeChange({ - channels: this.getSubscribedChannels(), - channelGroups: this.getSubscribedChannelGroups(), - }, isOffline); - }; - default_1.prototype.getHeartbeatChannels = function () { - return Object.keys(this._heartbeatChannels); - }; - default_1.prototype.getHeartbeatChannelGroups = function () { - return Object.keys(this._heartbeatChannelGroups); - }; - default_1.prototype.getSubscribedChannels = function () { - return Object.keys(this._channels); - }; - default_1.prototype.getSubscribedChannelGroups = function () { - return Object.keys(this._channelGroups); - }; - default_1.prototype.reconnect = function () { - this._startSubscribeLoop(); - this._registerHeartbeatTimer(); - }; - default_1.prototype.disconnect = function () { - this._stopSubscribeLoop(); - this._stopHeartbeatTimer(); - this._reconnectionManager.stopPolling(); - }; - default_1.prototype._registerHeartbeatTimer = function () { - this._stopHeartbeatTimer(); - // if the interval is 0 or undefined, do not queue up heartbeating - if (this._config.getHeartbeatInterval() === 0 || this._config.getHeartbeatInterval() === undefined) { - return; - } - this._performHeartbeatLoop(); - // $FlowFixMe - this._heartbeatTimer = setInterval(this._performHeartbeatLoop.bind(this), this._config.getHeartbeatInterval() * 1000); - }; - default_1.prototype._stopHeartbeatTimer = function () { - if (this._heartbeatTimer) { - // $FlowFixMe - clearInterval(this._heartbeatTimer); - this._heartbeatTimer = null; - } - }; - default_1.prototype._performHeartbeatLoop = function () { - var _this = this; - var heartbeatChannels = this.getHeartbeatChannels(); - var heartbeatChannelGroups = this.getHeartbeatChannelGroups(); - var presenceState = {}; - if (heartbeatChannels.length === 0 && heartbeatChannelGroups.length === 0) { - return; - } - this.getSubscribedChannels().forEach(function (channel) { - var channelState = _this._channels[channel].state; - if (Object.keys(channelState).length) { - presenceState[channel] = channelState; - } - }); - this.getSubscribedChannelGroups().forEach(function (channelGroup) { - var channelGroupState = _this._channelGroups[channelGroup].state; - if (Object.keys(channelGroupState).length) { - presenceState[channelGroup] = channelGroupState; - } - }); - var onHeartbeat = function (status) { - if (status.error && _this._config.announceFailedHeartbeats) { - _this._listenerManager.announceStatus(status); - } - if (status.error && _this._config.autoNetworkDetection && _this._isOnline) { - _this._isOnline = false; - _this.disconnect(); - _this._listenerManager.announceNetworkDown(); - _this.reconnect(); - } - if (!status.error && _this._config.announceSuccessfulHeartbeats) { - _this._listenerManager.announceStatus(status); - } - }; - this._heartbeatEndpoint({ - channels: heartbeatChannels, - channelGroups: heartbeatChannelGroups, - state: presenceState, - }, onHeartbeat.bind(this)); - }; - default_1.prototype._startSubscribeLoop = function () { - var _this = this; - this._stopSubscribeLoop(); - var presenceState = {}; - var channels = []; - var channelGroups = []; - Object.keys(this._channels).forEach(function (channel) { - var channelState = _this._channels[channel].state; - if (Object.keys(channelState).length) { - presenceState[channel] = channelState; - } - channels.push(channel); - }); - Object.keys(this._presenceChannels).forEach(function (channel) { - channels.push("".concat(channel, "-pnpres")); - }); - Object.keys(this._channelGroups).forEach(function (channelGroup) { - var channelGroupState = _this._channelGroups[channelGroup].state; - if (Object.keys(channelGroupState).length) { - presenceState[channelGroup] = channelGroupState; - } - channelGroups.push(channelGroup); - }); - Object.keys(this._presenceChannelGroups).forEach(function (channelGroup) { - channelGroups.push("".concat(channelGroup, "-pnpres")); - }); - if (channels.length === 0 && channelGroups.length === 0) { - return; - } - var subscribeArgs = { - channels: channels, - channelGroups: channelGroups, - state: presenceState, - timetoken: this._currentTimetoken, - filterExpression: this._config.filterExpression, - region: this._region, - }; - this._subscribeCall = this._subscribeEndpoint(subscribeArgs, this._processSubscribeResponse.bind(this)); - }; - default_1.prototype._processSubscribeResponse = function (status, payload) { - var _this = this; - if (status.error) { - // if error comes from request abort, ignore - if (status.errorData && status.errorData.message === 'Aborted') { - return; - } - // if we timeout from server, restart the loop. - if (status.category === categories.PNTimeoutCategory) { - this._startSubscribeLoop(); - } - else if (status.category === categories.PNNetworkIssuesCategory) { - // we lost internet connection, alert the reconnection manager and terminate all loops - this.disconnect(); - if (status.error && this._config.autoNetworkDetection && this._isOnline) { - this._isOnline = false; - this._listenerManager.announceNetworkDown(); - } - this._reconnectionManager.onReconnection(function () { - if (_this._config.autoNetworkDetection && !_this._isOnline) { - _this._isOnline = true; - _this._listenerManager.announceNetworkUp(); - } - _this.reconnect(); - _this._subscriptionStatusAnnounced = true; - var reconnectedAnnounce = { - category: categories.PNReconnectedCategory, - operation: status.operation, - lastTimetoken: _this._lastTimetoken, - currentTimetoken: _this._currentTimetoken, - }; - _this._listenerManager.announceStatus(reconnectedAnnounce); - }); - this._reconnectionManager.startPolling(); - this._listenerManager.announceStatus(status); - } - else if (status.category === categories.PNBadRequestCategory) { - this._stopHeartbeatTimer(); - this._listenerManager.announceStatus(status); - } - else { - this._listenerManager.announceStatus(status); - } - return; - } - if (this._storedTimetoken) { - this._currentTimetoken = this._storedTimetoken; - this._storedTimetoken = null; - } - else { - this._lastTimetoken = this._currentTimetoken; - this._currentTimetoken = payload.metadata.timetoken; - } - if (!this._subscriptionStatusAnnounced) { - var connectedAnnounce = {}; - connectedAnnounce.category = categories.PNConnectedCategory; - connectedAnnounce.operation = status.operation; - connectedAnnounce.affectedChannels = this._pendingChannelSubscriptions; - connectedAnnounce.subscribedChannels = this.getSubscribedChannels(); - connectedAnnounce.affectedChannelGroups = this._pendingChannelGroupSubscriptions; - connectedAnnounce.lastTimetoken = this._lastTimetoken; - connectedAnnounce.currentTimetoken = this._currentTimetoken; - this._subscriptionStatusAnnounced = true; - this._listenerManager.announceStatus(connectedAnnounce); - // clear the pending connections list - this._pendingChannelSubscriptions = []; - this._pendingChannelGroupSubscriptions = []; - } - var messages = payload.messages || []; - var _a = this._config, requestMessageCountThreshold = _a.requestMessageCountThreshold, dedupeOnSubscribe = _a.dedupeOnSubscribe; - if (requestMessageCountThreshold && messages.length >= requestMessageCountThreshold) { - var countAnnouncement = {}; - countAnnouncement.category = categories.PNRequestMessageCountExceededCategory; - countAnnouncement.operation = status.operation; - this._listenerManager.announceStatus(countAnnouncement); - } - messages.forEach(function (message) { - var channel = message.channel; - var subscriptionMatch = message.subscriptionMatch; - var publishMetaData = message.publishMetaData; - if (channel === subscriptionMatch) { - subscriptionMatch = null; - } - if (dedupeOnSubscribe) { - if (_this._dedupingManager.isDuplicate(message)) { - return; - } - _this._dedupingManager.addEntry(message); - } - if (utils$5.endsWith(message.channel, '-pnpres')) { - var announce = {}; - announce.channel = null; - announce.subscription = null; - // deprecated --> - announce.actualChannel = subscriptionMatch != null ? channel : null; - announce.subscribedChannel = subscriptionMatch != null ? subscriptionMatch : channel; - // <-- deprecated - if (channel) { - announce.channel = channel.substring(0, channel.lastIndexOf('-pnpres')); - } - if (subscriptionMatch) { - announce.subscription = subscriptionMatch.substring(0, subscriptionMatch.lastIndexOf('-pnpres')); - } - announce.action = message.payload.action; - announce.state = message.payload.data; - announce.timetoken = publishMetaData.publishTimetoken; - announce.occupancy = message.payload.occupancy; - announce.uuid = message.payload.uuid; - announce.timestamp = message.payload.timestamp; - if (message.payload.join) { - announce.join = message.payload.join; - } - if (message.payload.leave) { - announce.leave = message.payload.leave; - } - if (message.payload.timeout) { - announce.timeout = message.payload.timeout; - } - _this._listenerManager.announcePresence(announce); - } - else if (message.messageType === 1) { - // this is a signal message - var announce = {}; - announce.channel = null; - announce.subscription = null; - announce.channel = channel; - announce.subscription = subscriptionMatch; - announce.timetoken = publishMetaData.publishTimetoken; - announce.publisher = message.issuingClientId; - if (message.userMetadata) { - announce.userMetadata = message.userMetadata; - } - announce.message = message.payload; - _this._listenerManager.announceSignal(announce); - } - else if (message.messageType === 2) { - // this is an object message - var announce = {}; - announce.channel = null; - announce.subscription = null; - announce.channel = channel; - announce.subscription = subscriptionMatch; - announce.timetoken = publishMetaData.publishTimetoken; - announce.publisher = message.issuingClientId; - if (message.userMetadata) { - announce.userMetadata = message.userMetadata; - } - announce.message = { - event: message.payload.event, - type: message.payload.type, - data: message.payload.data, - }; - _this._listenerManager.announceObjects(announce); - if (message.payload.type === 'uuid') { - var eventData = _this._renameChannelField(announce); - _this._listenerManager.announceUser(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), type: 'user' }) })); - } - else if (message.payload.type === 'channel') { - var eventData = _this._renameChannelField(announce); - _this._listenerManager.announceSpace(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), type: 'space' }) })); - } - else if (message.payload.type === 'membership') { - var eventData = _this._renameChannelField(announce); - var _a = eventData.message.data, user = _a.uuid, space = _a.channel, membershipData = __rest(_a, ["uuid", "channel"]); - membershipData.user = user; - membershipData.space = space; - _this._listenerManager.announceMembership(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: _this._renameEvent(eventData.message.event), data: membershipData }) })); - } - } - else if (message.messageType === 3) { - // this is a message action - var announce = {}; - announce.channel = channel; - announce.subscription = subscriptionMatch; - announce.timetoken = publishMetaData.publishTimetoken; - announce.publisher = message.issuingClientId; - announce.data = { - messageTimetoken: message.payload.data.messageTimetoken, - actionTimetoken: message.payload.data.actionTimetoken, - type: message.payload.data.type, - uuid: message.issuingClientId, - value: message.payload.data.value, - }; - announce.event = message.payload.event; - _this._listenerManager.announceMessageAction(announce); - } - else if (message.messageType === 4) { - // this is a file message - var announce = {}; - announce.channel = channel; - announce.subscription = subscriptionMatch; - announce.timetoken = publishMetaData.publishTimetoken; - announce.publisher = message.issuingClientId; - var msgPayload = message.payload; - if (_this._config.cipherKey) { - var decryptedPayload = _this._crypto.decrypt(message.payload); - if (typeof decryptedPayload === 'object' && decryptedPayload !== null) { - msgPayload = decryptedPayload; - } - } - if (message.userMetadata) { - announce.userMetadata = message.userMetadata; - } - announce.message = msgPayload.message; - announce.file = { - id: msgPayload.file.id, - name: msgPayload.file.name, - url: _this._getFileUrl({ - id: msgPayload.file.id, - name: msgPayload.file.name, - channel: channel, - }), - }; - _this._listenerManager.announceFile(announce); - } - else { - var announce = {}; - announce.channel = null; - announce.subscription = null; - // deprecated --> - announce.actualChannel = subscriptionMatch != null ? channel : null; - announce.subscribedChannel = subscriptionMatch != null ? subscriptionMatch : channel; - // <-- deprecated - announce.channel = channel; - announce.subscription = subscriptionMatch; - announce.timetoken = publishMetaData.publishTimetoken; - announce.publisher = message.issuingClientId; - if (message.userMetadata) { - announce.userMetadata = message.userMetadata; - } - if (_this._config.cipherKey) { - announce.message = _this._crypto.decrypt(message.payload); - } - else { - announce.message = message.payload; - } - _this._listenerManager.announceMessage(announce); - } - }); - this._region = payload.metadata.region; - this._startSubscribeLoop(); - }; - default_1.prototype._stopSubscribeLoop = function () { - if (this._subscribeCall) { - if (typeof this._subscribeCall.abort === 'function') { - this._subscribeCall.abort(); - } - this._subscribeCall = null; - } - }; - default_1.prototype._renameEvent = function (e) { - return e === 'set' ? 'updated' : 'removed'; - }; - default_1.prototype._renameChannelField = function (announce) { - var channel = announce.channel, eventData = __rest(announce, ["channel"]); - eventData.spaceId = channel; - return eventData; - }; - return default_1; - }()); - - /* */ - var OPERATIONS = { - PNTimeOperation: 'PNTimeOperation', - PNHistoryOperation: 'PNHistoryOperation', - PNDeleteMessagesOperation: 'PNDeleteMessagesOperation', - PNFetchMessagesOperation: 'PNFetchMessagesOperation', - PNMessageCounts: 'PNMessageCountsOperation', - // pubsub - PNSubscribeOperation: 'PNSubscribeOperation', - PNUnsubscribeOperation: 'PNUnsubscribeOperation', - PNPublishOperation: 'PNPublishOperation', - PNSignalOperation: 'PNSignalOperation', - // Actions API - PNAddMessageActionOperation: 'PNAddActionOperation', - PNRemoveMessageActionOperation: 'PNRemoveMessageActionOperation', - PNGetMessageActionsOperation: 'PNGetMessageActionsOperation', - // Objects API - PNCreateUserOperation: 'PNCreateUserOperation', - PNUpdateUserOperation: 'PNUpdateUserOperation', - PNDeleteUserOperation: 'PNDeleteUserOperation', - PNGetUserOperation: 'PNGetUsersOperation', - PNGetUsersOperation: 'PNGetUsersOperation', - PNCreateSpaceOperation: 'PNCreateSpaceOperation', - PNUpdateSpaceOperation: 'PNUpdateSpaceOperation', - PNDeleteSpaceOperation: 'PNDeleteSpaceOperation', - PNGetSpaceOperation: 'PNGetSpacesOperation', - PNGetSpacesOperation: 'PNGetSpacesOperation', - PNGetMembersOperation: 'PNGetMembersOperation', - PNUpdateMembersOperation: 'PNUpdateMembersOperation', - PNGetMembershipsOperation: 'PNGetMembershipsOperation', - PNUpdateMembershipsOperation: 'PNUpdateMembershipsOperation', - // File Upload API v1 - PNListFilesOperation: 'PNListFilesOperation', - PNGenerateUploadUrlOperation: 'PNGenerateUploadUrlOperation', - PNPublishFileOperation: 'PNPublishFileOperation', - PNGetFileUrlOperation: 'PNGetFileUrlOperation', - PNDownloadFileOperation: 'PNDownloadFileOperation', - // Objects API v2 - // UUID - PNGetAllUUIDMetadataOperation: 'PNGetAllUUIDMetadataOperation', - PNGetUUIDMetadataOperation: 'PNGetUUIDMetadataOperation', - PNSetUUIDMetadataOperation: 'PNSetUUIDMetadataOperation', - PNRemoveUUIDMetadataOperation: 'PNRemoveUUIDMetadataOperation', - // channel - PNGetAllChannelMetadataOperation: 'PNGetAllChannelMetadataOperation', - PNGetChannelMetadataOperation: 'PNGetChannelMetadataOperation', - PNSetChannelMetadataOperation: 'PNSetChannelMetadataOperation', - PNRemoveChannelMetadataOperation: 'PNRemoveChannelMetadataOperation', - // member - // PNGetMembersOperation: 'PNGetMembersOperation', - PNSetMembersOperation: 'PNSetMembersOperation', - // PNGetMembershipsOperation: 'PNGetMembersOperation', - PNSetMembershipsOperation: 'PNSetMembershipsOperation', - // push - PNPushNotificationEnabledChannelsOperation: 'PNPushNotificationEnabledChannelsOperation', - PNRemoveAllPushNotificationsOperation: 'PNRemoveAllPushNotificationsOperation', - // - // presence - PNWhereNowOperation: 'PNWhereNowOperation', - PNSetStateOperation: 'PNSetStateOperation', - PNHereNowOperation: 'PNHereNowOperation', - PNGetStateOperation: 'PNGetStateOperation', - PNHeartbeatOperation: 'PNHeartbeatOperation', - // - // channel group - PNChannelGroupsOperation: 'PNChannelGroupsOperation', - PNRemoveGroupOperation: 'PNRemoveGroupOperation', - PNChannelsForGroupOperation: 'PNChannelsForGroupOperation', - PNAddChannelsToGroupOperation: 'PNAddChannelsToGroupOperation', - PNRemoveChannelsFromGroupOperation: 'PNRemoveChannelsFromGroupOperation', - // - // PAM - PNAccessManagerGrant: 'PNAccessManagerGrant', - PNAccessManagerGrantToken: 'PNAccessManagerGrantToken', - PNAccessManagerAudit: 'PNAccessManagerAudit', - PNAccessManagerRevokeToken: 'PNAccessManagerRevokeToken', - // - // subscription utilities - PNHandshakeOperation: 'PNHandshakeOperation', - PNReceiveMessagesOperation: 'PNReceiveMessagesOperation', - }; - - /* */ - var default_1$6 = /** @class */ (function () { - function default_1(configuration) { - this._maximumSamplesCount = 100; - this._trackedLatencies = {}; - this._latencies = {}; - this._maximumSamplesCount = configuration.maximumSamplesCount || this._maximumSamplesCount; - } - /** - * Compose object with latency information of recently used API endpoints. - * - * @return {Object} Object with request query key/value pairs. - */ - default_1.prototype.operationsLatencyForRequest = function () { - var _this = this; - var latencies = {}; - Object.keys(this._latencies).forEach(function (endpointName) { - var operationLatencies = _this._latencies[endpointName]; - var averageLatency = _this._averageLatency(operationLatencies); - if (averageLatency > 0) { - latencies["l_".concat(endpointName)] = averageLatency; - } - }); - return latencies; - }; - default_1.prototype.startLatencyMeasure = function (operationType, identifier) { - if (operationType === OPERATIONS.PNSubscribeOperation || !identifier) { - return; - } - this._trackedLatencies[identifier] = Date.now(); - }; - default_1.prototype.stopLatencyMeasure = function (operationType, identifier) { - if (operationType === OPERATIONS.PNSubscribeOperation || !identifier) { - return; - } - var endpointName = this._endpointName(operationType); - /** @type Array */ - var endpointLatencies = this._latencies[endpointName]; - var startDate = this._trackedLatencies[identifier]; - if (!endpointLatencies) { - this._latencies[endpointName] = []; - endpointLatencies = this._latencies[endpointName]; - } - endpointLatencies.push(Date.now() - startDate); - // Truncate samples count if there is more then configured. - if (endpointLatencies.length > this._maximumSamplesCount) { - endpointLatencies.splice(0, endpointLatencies.length - this._maximumSamplesCount); - } - delete this._trackedLatencies[identifier]; - }; - default_1.prototype._averageLatency = function (latencies) { - var arrayReduce = function (accumulatedLatency, latency) { return accumulatedLatency + latency; }; - return Math.floor(latencies.reduce(arrayReduce, 0) / latencies.length); - }; - default_1.prototype._endpointName = function (operationType) { - var operation = null; - switch (operationType) { - case OPERATIONS.PNPublishOperation: - operation = 'pub'; - break; - case OPERATIONS.PNSignalOperation: - operation = 'sig'; - break; - case OPERATIONS.PNHistoryOperation: - case OPERATIONS.PNFetchMessagesOperation: - case OPERATIONS.PNDeleteMessagesOperation: - case OPERATIONS.PNMessageCounts: - operation = 'hist'; - break; - case OPERATIONS.PNUnsubscribeOperation: - case OPERATIONS.PNWhereNowOperation: - case OPERATIONS.PNHereNowOperation: - case OPERATIONS.PNHeartbeatOperation: - case OPERATIONS.PNSetStateOperation: - case OPERATIONS.PNGetStateOperation: - operation = 'pres'; - break; - case OPERATIONS.PNAddChannelsToGroupOperation: - case OPERATIONS.PNRemoveChannelsFromGroupOperation: - case OPERATIONS.PNChannelGroupsOperation: - case OPERATIONS.PNRemoveGroupOperation: - case OPERATIONS.PNChannelsForGroupOperation: - operation = 'cg'; - break; - case OPERATIONS.PNPushNotificationEnabledChannelsOperation: - case OPERATIONS.PNRemoveAllPushNotificationsOperation: - operation = 'push'; - break; - case OPERATIONS.PNCreateUserOperation: - case OPERATIONS.PNUpdateUserOperation: - case OPERATIONS.PNDeleteUserOperation: - case OPERATIONS.PNGetUserOperation: - case OPERATIONS.PNGetUsersOperation: - case OPERATIONS.PNCreateSpaceOperation: - case OPERATIONS.PNUpdateSpaceOperation: - case OPERATIONS.PNDeleteSpaceOperation: - case OPERATIONS.PNGetSpaceOperation: - case OPERATIONS.PNGetSpacesOperation: - case OPERATIONS.PNGetMembersOperation: - case OPERATIONS.PNUpdateMembersOperation: - case OPERATIONS.PNGetMembershipsOperation: - case OPERATIONS.PNUpdateMembershipsOperation: - operation = 'obj'; - break; - case OPERATIONS.PNAddMessageActionOperation: - case OPERATIONS.PNRemoveMessageActionOperation: - case OPERATIONS.PNGetMessageActionsOperation: - operation = 'msga'; - break; - case OPERATIONS.PNAccessManagerGrant: - case OPERATIONS.PNAccessManagerAudit: - operation = 'pam'; - break; - case OPERATIONS.PNAccessManagerGrantToken: - case OPERATIONS.PNAccessManagerRevokeToken: - operation = 'pamv3'; - break; - default: - operation = 'time'; - break; - } - return operation; - }; - return default_1; - }()); - - var BaseNotificationPayload = /** @class */ (function () { - function BaseNotificationPayload(payload, title, body) { - this._payload = payload; - this._setDefaultPayloadStructure(); - this.title = title; - this.body = body; - } - Object.defineProperty(BaseNotificationPayload.prototype, "payload", { - get: function () { - return this._payload; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseNotificationPayload.prototype, "title", { - set: function (value) { - this._title = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseNotificationPayload.prototype, "subtitle", { - set: function (value) { - this._subtitle = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseNotificationPayload.prototype, "body", { - set: function (value) { - this._body = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseNotificationPayload.prototype, "badge", { - set: function (value) { - this._badge = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(BaseNotificationPayload.prototype, "sound", { - set: function (value) { - this._sound = value; - }, - enumerable: false, - configurable: true - }); - BaseNotificationPayload.prototype._setDefaultPayloadStructure = function () { - // Empty. - }; - BaseNotificationPayload.prototype.toObject = function () { - return {}; - }; - return BaseNotificationPayload; - }()); - var APNSNotificationPayload = /** @class */ (function (_super) { - __extends(APNSNotificationPayload, _super); - function APNSNotificationPayload() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(APNSNotificationPayload.prototype, "configurations", { - set: function (value) { - if (!value || !value.length) - return; - this._configurations = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(APNSNotificationPayload.prototype, "notification", { - get: function () { - return this._payload.aps; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(APNSNotificationPayload.prototype, "title", { - get: function () { - return this._title; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.aps.alert.title = value; - this._title = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(APNSNotificationPayload.prototype, "subtitle", { - get: function () { - return this._subtitle; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.aps.alert.subtitle = value; - this._subtitle = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(APNSNotificationPayload.prototype, "body", { - get: function () { - return this._body; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.aps.alert.body = value; - this._body = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(APNSNotificationPayload.prototype, "badge", { - get: function () { - return this._badge; - }, - set: function (value) { - if (value === undefined || value === null) - return; - this._payload.aps.badge = value; - this._badge = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(APNSNotificationPayload.prototype, "sound", { - get: function () { - return this._sound; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.aps.sound = value; - this._sound = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(APNSNotificationPayload.prototype, "silent", { - set: function (value) { - this._isSilent = value; - }, - enumerable: false, - configurable: true - }); - APNSNotificationPayload.prototype._setDefaultPayloadStructure = function () { - this._payload.aps = { alert: {} }; - }; - APNSNotificationPayload.prototype.toObject = function () { - var _this = this; - var payload = __assign({}, this._payload); - /** @type {{alert: Object, badge: number, sound: string}} */ - var aps = payload.aps; - var alert = aps.alert; - if (this._isSilent) { - aps['content-available'] = 1; - } - if (this._apnsPushType === 'apns2') { - if (!this._configurations || !this._configurations.length) { - throw new ReferenceError('APNS2 configuration is missing'); - } - var configurations_1 = []; - this._configurations.forEach(function (configuration) { - configurations_1.push(_this._objectFromAPNS2Configuration(configuration)); - }); - if (configurations_1.length) { - payload.pn_push = configurations_1; - } - } - if (!alert || !Object.keys(alert).length) { - delete aps.alert; - } - if (this._isSilent) { - delete aps.alert; - delete aps.badge; - delete aps.sound; - alert = {}; - } - return this._isSilent || Object.keys(alert).length ? payload : null; - }; - APNSNotificationPayload.prototype._objectFromAPNS2Configuration = function (configuration) { - var _this = this; - if (!configuration.targets || !configuration.targets.length) { - throw new ReferenceError('At least one APNS2 target should be provided'); - } - var targets = []; - configuration.targets.forEach(function (target) { - targets.push(_this._objectFromAPNSTarget(target)); - }); - var collapseId = configuration.collapseId, expirationDate = configuration.expirationDate; - var objectifiedConfiguration = { auth_method: 'token', targets: targets, version: 'v2' }; - if (collapseId && collapseId.length) { - objectifiedConfiguration.collapse_id = collapseId; - } - if (expirationDate) { - objectifiedConfiguration.expiration = expirationDate.toISOString(); - } - return objectifiedConfiguration; - }; - APNSNotificationPayload.prototype._objectFromAPNSTarget = function (target) { - if (!target.topic || !target.topic.length) { - throw new TypeError("Target 'topic' undefined."); - } - var topic = target.topic, _a = target.environment, environment = _a === void 0 ? 'development' : _a, _b = target.excludedDevices, excludedDevices = _b === void 0 ? [] : _b; - var objectifiedTarget = { topic: topic, environment: environment }; - if (excludedDevices.length) { - objectifiedTarget.excluded_devices = excludedDevices; - } - return objectifiedTarget; - }; - return APNSNotificationPayload; - }(BaseNotificationPayload)); - var MPNSNotificationPayload = /** @class */ (function (_super) { - __extends(MPNSNotificationPayload, _super); - function MPNSNotificationPayload() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(MPNSNotificationPayload.prototype, "backContent", { - get: function () { - return this._backContent; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.back_content = value; - this._backContent = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(MPNSNotificationPayload.prototype, "backTitle", { - get: function () { - return this._backTitle; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.back_title = value; - this._backTitle = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(MPNSNotificationPayload.prototype, "count", { - get: function () { - return this._count; - }, - set: function (value) { - if (value === undefined || value === null) - return; - this._payload.count = value; - this._count = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(MPNSNotificationPayload.prototype, "title", { - get: function () { - return this._title; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.title = value; - this._title = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(MPNSNotificationPayload.prototype, "type", { - get: function () { - return this._type; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.type = value; - this._type = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(MPNSNotificationPayload.prototype, "subtitle", { - get: function () { - return this.backTitle; - }, - set: function (value) { - this.backTitle = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(MPNSNotificationPayload.prototype, "body", { - get: function () { - return this.backContent; - }, - set: function (value) { - this.backContent = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(MPNSNotificationPayload.prototype, "badge", { - get: function () { - return this.count; - }, - set: function (value) { - this.count = value; - }, - enumerable: false, - configurable: true - }); - MPNSNotificationPayload.prototype.toObject = function () { - return Object.keys(this._payload).length ? __assign({}, this._payload) : null; - }; - return MPNSNotificationPayload; - }(BaseNotificationPayload)); - var FCMNotificationPayload = /** @class */ (function (_super) { - __extends(FCMNotificationPayload, _super); - function FCMNotificationPayload() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(FCMNotificationPayload.prototype, "notification", { - get: function () { - return this._payload.notification; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FCMNotificationPayload.prototype, "data", { - get: function () { - return this._payload.data; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FCMNotificationPayload.prototype, "title", { - get: function () { - return this._title; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.notification.title = value; - this._title = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FCMNotificationPayload.prototype, "body", { - get: function () { - return this._body; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.notification.body = value; - this._body = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FCMNotificationPayload.prototype, "sound", { - get: function () { - return this._sound; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.notification.sound = value; - this._sound = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FCMNotificationPayload.prototype, "icon", { - get: function () { - return this._icon; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.notification.icon = value; - this._icon = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FCMNotificationPayload.prototype, "tag", { - get: function () { - return this._tag; - }, - set: function (value) { - if (!value || !value.length) - return; - this._payload.notification.tag = value; - this._tag = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(FCMNotificationPayload.prototype, "silent", { - set: function (value) { - this._isSilent = value; - }, - enumerable: false, - configurable: true - }); - FCMNotificationPayload.prototype._setDefaultPayloadStructure = function () { - this._payload.notification = {}; - this._payload.data = {}; - }; - FCMNotificationPayload.prototype.toObject = function () { - var data = __assign({}, this._payload.data); - var notification = null; - var payload = {}; - /** - * Check whether additional data has been passed outside of 'data' object - * and put it into it if required. - */ - if (Object.keys(this._payload).length > 2) { - var _a = this._payload; _a.notification; _a.data; var additionalData = __rest(_a, ["notification", "data"]); - data = __assign(__assign({}, data), additionalData); - } - if (this._isSilent) { - data.notification = this._payload.notification; - } - else { - notification = this._payload.notification; - } - if (Object.keys(data).length) { - payload.data = data; - } - if (notification && Object.keys(notification).length) { - payload.notification = notification; - } - return Object.keys(payload).length ? payload : null; - }; - return FCMNotificationPayload; - }(BaseNotificationPayload)); - var NotificationsPayload = /** @class */ (function () { - function NotificationsPayload(title, body) { - this._payload = { apns: {}, mpns: {}, fcm: {} }; - this._title = title; - this._body = body; - this.apns = new APNSNotificationPayload(this._payload.apns, title, body); - this.mpns = new MPNSNotificationPayload(this._payload.mpns, title, body); - this.fcm = new FCMNotificationPayload(this._payload.fcm, title, body); - } - Object.defineProperty(NotificationsPayload.prototype, "debugging", { - set: function (value) { - this._debugging = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(NotificationsPayload.prototype, "title", { - get: function () { - return this._title; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(NotificationsPayload.prototype, "body", { - get: function () { - return this._body; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(NotificationsPayload.prototype, "subtitle", { - get: function () { - return this._subtitle; - }, - set: function (value) { - this._subtitle = value; - this.apns.subtitle = value; - this.mpns.subtitle = value; - this.fcm.subtitle = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(NotificationsPayload.prototype, "badge", { - get: function () { - return this._badge; - }, - set: function (value) { - this._badge = value; - this.apns.badge = value; - this.mpns.badge = value; - this.fcm.badge = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(NotificationsPayload.prototype, "sound", { - get: function () { - return this._sound; - }, - set: function (value) { - this._sound = value; - this.apns.sound = value; - this.mpns.sound = value; - this.fcm.sound = value; - }, - enumerable: false, - configurable: true - }); - /** - * Build notifications platform for requested platforms. - * - * @param {Array} platforms - List of platforms for which payload - * should be added to final dictionary. Supported values: gcm, apns, apns2, - * mpns. - * - * @returns {Object} Object with data, which can be sent with publish method - * call and trigger remote notifications for specified platforms. - */ - NotificationsPayload.prototype.buildPayload = function (platforms) { - var payload = {}; - if (platforms.includes('apns') || platforms.includes('apns2')) { - this.apns._apnsPushType = platforms.includes('apns') ? 'apns' : 'apns2'; - var apnsPayload = this.apns.toObject(); - if (apnsPayload && Object.keys(apnsPayload).length) { - payload.pn_apns = apnsPayload; - } - } - if (platforms.includes('mpns')) { - var mpnsPayload = this.mpns.toObject(); - if (mpnsPayload && Object.keys(mpnsPayload).length) { - payload.pn_mpns = mpnsPayload; - } - } - if (platforms.includes('fcm')) { - var fcmPayload = this.fcm.toObject(); - if (fcmPayload && Object.keys(fcmPayload).length) { - payload.pn_gcm = fcmPayload; - } - } - if (Object.keys(payload).length && this._debugging) { - payload.pn_debug = true; - } - return payload; - }; - return NotificationsPayload; - }()); - - var default_1$5 = /** @class */ (function () { - function default_1() { - this._listeners = []; - } - default_1.prototype.addListener = function (newListeners) { - this._listeners.push(newListeners); - }; - default_1.prototype.removeListener = function (deprecatedListener) { - var newListeners = []; - this._listeners.forEach(function (listener) { - if (listener !== deprecatedListener) - newListeners.push(listener); - }); - this._listeners = newListeners; - }; - default_1.prototype.removeAllListeners = function () { - this._listeners = []; - }; - default_1.prototype.announcePresence = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.presence) - listener.presence(announce); - }); - }; - default_1.prototype.announceStatus = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.status) - listener.status(announce); - }); - }; - default_1.prototype.announceMessage = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.message) - listener.message(announce); - }); - }; - default_1.prototype.announceSignal = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.signal) - listener.signal(announce); - }); - }; - default_1.prototype.announceMessageAction = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.messageAction) - listener.messageAction(announce); - }); - }; - default_1.prototype.announceFile = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.file) - listener.file(announce); - }); - }; - default_1.prototype.announceObjects = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.objects) - listener.objects(announce); - }); - }; - default_1.prototype.announceUser = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.user) - listener.user(announce); - }); - }; - default_1.prototype.announceSpace = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.space) - listener.space(announce); - }); - }; - default_1.prototype.announceMembership = function (announce) { - this._listeners.forEach(function (listener) { - if (listener.membership) - listener.membership(announce); - }); - }; - default_1.prototype.announceNetworkUp = function () { - var networkStatus = {}; - networkStatus.category = categories.PNNetworkUpCategory; - this.announceStatus(networkStatus); - }; - default_1.prototype.announceNetworkDown = function () { - var networkStatus = {}; - networkStatus.category = categories.PNNetworkDownCategory; - this.announceStatus(networkStatus); - }; - return default_1; - }()); - - var default_1$4 = /** @class */ (function () { - function default_1(config, cbor) { - this._config = config; - this._cbor = cbor; - } - default_1.prototype.setToken = function (token) { - if (token && token.length > 0) { - this._token = token; - } - else { - this._token = undefined; - } - }; - default_1.prototype.getToken = function () { - return this._token; - }; - default_1.prototype.extractPermissions = function (permissions) { - var permissionsResult = { - read: false, - write: false, - manage: false, - delete: false, - get: false, - update: false, - join: false, - }; - /* eslint-disable */ - if ((permissions & 128) === 128) { - permissionsResult.join = true; - } - if ((permissions & 64) === 64) { - permissionsResult.update = true; - } - if ((permissions & 32) === 32) { - permissionsResult.get = true; - } - if ((permissions & 8) === 8) { - permissionsResult.delete = true; - } - if ((permissions & 4) === 4) { - permissionsResult.manage = true; - } - if ((permissions & 2) === 2) { - permissionsResult.write = true; - } - if ((permissions & 1) === 1) { - permissionsResult.read = true; - } - /* eslint-enable */ - return permissionsResult; - }; - default_1.prototype.parseToken = function (tokenString) { - var _this = this; - var parsed = this._cbor.decodeToken(tokenString); - if (parsed !== undefined) { - var uuidResourcePermissions = parsed.res.uuid ? Object.keys(parsed.res.uuid) : []; - var channelResourcePermissions = Object.keys(parsed.res.chan); - var groupResourcePermissions = Object.keys(parsed.res.grp); - var uuidPatternPermissions = parsed.pat.uuid ? Object.keys(parsed.pat.uuid) : []; - var channelPatternPermissions = Object.keys(parsed.pat.chan); - var groupPatternPermissions = Object.keys(parsed.pat.grp); - var result_1 = { - version: parsed.v, - timestamp: parsed.t, - ttl: parsed.ttl, - authorized_uuid: parsed.uuid, - }; - var uuidResources = uuidResourcePermissions.length > 0; - var channelResources = channelResourcePermissions.length > 0; - var groupResources = groupResourcePermissions.length > 0; - if (uuidResources || channelResources || groupResources) { - result_1.resources = {}; - if (uuidResources) { - result_1.resources.uuids = {}; - uuidResourcePermissions.forEach(function (id) { - result_1.resources.uuids[id] = _this.extractPermissions(parsed.res.uuid[id]); - }); - } - if (channelResources) { - result_1.resources.channels = {}; - channelResourcePermissions.forEach(function (id) { - result_1.resources.channels[id] = _this.extractPermissions(parsed.res.chan[id]); - }); - } - if (groupResources) { - result_1.resources.groups = {}; - groupResourcePermissions.forEach(function (id) { - result_1.resources.groups[id] = _this.extractPermissions(parsed.res.grp[id]); - }); - } - } - var uuidPatterns = uuidPatternPermissions.length > 0; - var channelPatterns = channelPatternPermissions.length > 0; - var groupPatterns = groupPatternPermissions.length > 0; - if (uuidPatterns || channelPatterns || groupPatterns) { - result_1.patterns = {}; - if (uuidPatterns) { - result_1.patterns.uuids = {}; - uuidPatternPermissions.forEach(function (id) { - result_1.patterns.uuids[id] = _this.extractPermissions(parsed.pat.uuid[id]); - }); - } - if (channelPatterns) { - result_1.patterns.channels = {}; - channelPatternPermissions.forEach(function (id) { - result_1.patterns.channels[id] = _this.extractPermissions(parsed.pat.chan[id]); - }); - } - if (groupPatterns) { - result_1.patterns.groups = {}; - groupPatternPermissions.forEach(function (id) { - result_1.patterns.groups[id] = _this.extractPermissions(parsed.pat.grp[id]); - }); - } - } - if (Object.keys(parsed.meta).length > 0) { - result_1.meta = parsed.meta; - } - result_1.signature = parsed.sig; - return result_1; - } - return undefined; - }; - return default_1; - }()); - - var PubNubError = /** @class */ (function (_super) { - __extends(PubNubError, _super); - function PubNubError(message, status) { - var _newTarget = this.constructor; - var _this = _super.call(this, message) || this; - _this.name = _this.constructor.name; - _this.status = status; - _this.message = message; - Object.setPrototypeOf(_this, _newTarget.prototype); - return _this; - } - return PubNubError; - }(Error)); - function createError(errorPayload, type) { - errorPayload.type = type; - errorPayload.error = true; - return errorPayload; - } - function createValidationError(message) { - return createError({ message: message }, 'validationError'); - } - function decideURL(endpoint, modules, incomingParams) { - if (endpoint.usePost && endpoint.usePost(modules, incomingParams)) { - return endpoint.postURL(modules, incomingParams); - } - if (endpoint.usePatch && endpoint.usePatch(modules, incomingParams)) { - return endpoint.patchURL(modules, incomingParams); - } - if (endpoint.useGetFile && endpoint.useGetFile(modules, incomingParams)) { - return endpoint.getFileURL(modules, incomingParams); - } - return endpoint.getURL(modules, incomingParams); - } - function generatePNSDK(config) { - if (config.sdkName) { - return config.sdkName; - } - var base = "PubNub-JS-".concat(config.sdkFamily); - if (config.partnerId) { - base += "-".concat(config.partnerId); - } - base += "/".concat(config.getVersion()); - var pnsdkSuffix = config._getPnsdkSuffix(' '); - if (pnsdkSuffix.length > 0) { - base += pnsdkSuffix; - } - return base; - } - function getHttpMethod(modules, endpoint, incomingParams) { - if (endpoint.usePost && endpoint.usePost(modules, incomingParams)) { - return 'POST'; - } - if (endpoint.usePatch && endpoint.usePatch(modules, incomingParams)) { - return 'PATCH'; - } - if (endpoint.useDelete && endpoint.useDelete(modules, incomingParams)) { - return 'DELETE'; - } - if (endpoint.useGetFile && endpoint.useGetFile(modules, incomingParams)) { - return 'GETFILE'; - } - return 'GET'; - } - function signRequest(modules, url, outgoingParams, incomingParams, endpoint) { - var config = modules.config, crypto = modules.crypto; - var httpMethod = getHttpMethod(modules, endpoint, incomingParams); - outgoingParams.timestamp = Math.floor(new Date().getTime() / 1000); - // This is because of a server-side bug, old publish using post should be deprecated - if (endpoint.getOperation() === 'PNPublishOperation' && - endpoint.usePost && - endpoint.usePost(modules, incomingParams)) { - httpMethod = 'GET'; - } - if (httpMethod === 'GETFILE') { - httpMethod = 'GET'; - } - var signInput = "".concat(httpMethod, "\n").concat(config.publishKey, "\n").concat(url, "\n").concat(utils$5.signPamFromParams(outgoingParams), "\n"); - if (httpMethod === 'POST') { - var payload = endpoint.postPayload(modules, incomingParams); - if (typeof payload === 'string') { - signInput += payload; - } - else { - signInput += JSON.stringify(payload); - } - } - else if (httpMethod === 'PATCH') { - var payload = endpoint.patchPayload(modules, incomingParams); - if (typeof payload === 'string') { - signInput += payload; - } - else { - signInput += JSON.stringify(payload); - } - } - var signature = "v2.".concat(crypto.HMACSHA256(signInput)); - signature = signature.replace(/\+/g, '-'); - signature = signature.replace(/\//g, '_'); - signature = signature.replace(/=+$/, ''); - outgoingParams.signature = signature; - } - function endpointCreator (modules, endpoint) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } - var networking = modules.networking, config = modules.config, telemetryManager = modules.telemetryManager, tokenManager = modules.tokenManager; - var requestId = uuidGenerator.createUUID(); - var callback = null; - var promiseComponent = null; - var incomingParams = {}; - if (endpoint.getOperation() === OPERATIONS.PNTimeOperation || - endpoint.getOperation() === OPERATIONS.PNChannelGroupsOperation) { - callback = args[0]; - } - else { - incomingParams = args[0]; - callback = args[1]; - } - // bridge in Promise support. - if (typeof Promise !== 'undefined' && !callback) { - promiseComponent = utils$5.createPromise(); - } - var validationResult = endpoint.validateParams(modules, incomingParams); - if (validationResult) { - if (callback) { - return callback(createValidationError(validationResult)); - } - if (promiseComponent) { - promiseComponent.reject(new PubNubError('Validation failed, check status for details', createValidationError(validationResult))); - return promiseComponent.promise; - } - return; - } - var outgoingParams = endpoint.prepareParams(modules, incomingParams); - var url = decideURL(endpoint, modules, incomingParams); - var callInstance; - var networkingParams = { - url: url, - operation: endpoint.getOperation(), - timeout: endpoint.getRequestTimeout(modules), - headers: endpoint.getRequestHeaders ? endpoint.getRequestHeaders() : {}, - ignoreBody: typeof endpoint.ignoreBody === 'function' ? endpoint.ignoreBody(modules) : false, - forceBuffered: typeof endpoint.forceBuffered === 'function' ? endpoint.forceBuffered(modules, incomingParams) : null, - abortSignal: typeof endpoint.getAbortSignal === 'function' ? endpoint.getAbortSignal(modules, incomingParams) : null, - }; - outgoingParams.uuid = config.UUID; - outgoingParams.pnsdk = generatePNSDK(config); - // Add telemetry information (if there is any available). - var telemetryLatencies = telemetryManager.operationsLatencyForRequest(); - if (Object.keys(telemetryLatencies).length) { - outgoingParams = __assign(__assign({}, outgoingParams), telemetryLatencies); - } - if (config.useInstanceId) { - outgoingParams.instanceid = config.instanceId; - } - if (config.useRequestId) { - outgoingParams.requestid = requestId; - } - if (endpoint.isAuthSupported()) { - var tokenOrKey = tokenManager.getToken() || config.getAuthKey(); - if (tokenOrKey) { - outgoingParams.auth = tokenOrKey; - } - } - if (config.secretKey) { - signRequest(modules, url, outgoingParams, incomingParams, endpoint); - } - var onResponse = function (status, payload) { - if (status.error) { - if (endpoint.handleError) { - endpoint.handleError(modules, incomingParams, status); - } - if (callback) { - callback(status); - } - else if (promiseComponent) { - promiseComponent.reject(new PubNubError('PubNub call failed, check status for details', status)); - } - return; - } - // Stop endpoint latency tracking. - telemetryManager.stopLatencyMeasure(endpoint.getOperation(), requestId); - var responseP = endpoint.handleResponse(modules, payload, incomingParams); - if (typeof (responseP === null || responseP === void 0 ? void 0 : responseP.then) !== 'function') { - responseP = Promise.resolve(responseP); - } - responseP - .then(function (result) { - if (callback) { - callback(status, result); - } - else if (promiseComponent) { - promiseComponent.fulfill(result); - } - }) - .catch(function (e) { - if (callback) { - var errorData = e; - if (endpoint.getOperation() === OPERATIONS.PNSubscribeOperation) { - errorData = { - statusCode: 400, - error: true, - operation: endpoint.getOperation(), - errorData: e, - category: categories.PNUnknownCategory, - }; - } - callback(errorData, null); - } - else if (promiseComponent) { - promiseComponent.reject(new PubNubError('PubNub call failed, check status for details', e)); - } - }); - }; - // Start endpoint latency tracking. - telemetryManager.startLatencyMeasure(endpoint.getOperation(), requestId); - if (getHttpMethod(modules, endpoint, incomingParams) === 'POST') { - var payload = endpoint.postPayload(modules, incomingParams); - callInstance = networking.POST(outgoingParams, payload, networkingParams, onResponse); - } - else if (getHttpMethod(modules, endpoint, incomingParams) === 'PATCH') { - var payload = endpoint.patchPayload(modules, incomingParams); - callInstance = networking.PATCH(outgoingParams, payload, networkingParams, onResponse); - } - else if (getHttpMethod(modules, endpoint, incomingParams) === 'DELETE') { - callInstance = networking.DELETE(outgoingParams, networkingParams, onResponse); - } - else if (getHttpMethod(modules, endpoint, incomingParams) === 'GETFILE') { - callInstance = networking.GETFILE(outgoingParams, networkingParams, onResponse); - } - else { - callInstance = networking.GET(outgoingParams, networkingParams, onResponse); - } - if (endpoint.getOperation() === OPERATIONS.PNSubscribeOperation) { - return callInstance; - } - if (promiseComponent) { - return promiseComponent.promise; - } - } - - /* */ - function getOperation$s() { - return OPERATIONS.PNAddChannelsToGroupOperation; - } - function validateParams$s(modules, incomingParams) { - var channels = incomingParams.channels, channelGroup = incomingParams.channelGroup; - var config = modules.config; - if (!channelGroup) - return 'Missing Channel Group'; - if (!channels || channels.length === 0) - return 'Missing Channels'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$q(modules, incomingParams) { - var channelGroup = incomingParams.channelGroup; - var config = modules.config; - return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup)); - } - function getRequestTimeout$s(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$s() { - return true; - } - function prepareParams$s(modules, incomingParams) { - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; - return { - add: channels.join(','), - }; - } - function handleResponse$s() { - return {}; - } - - var addChannelsChannelGroupConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$s, - validateParams: validateParams$s, - getURL: getURL$q, - getRequestTimeout: getRequestTimeout$s, - isAuthSupported: isAuthSupported$s, - prepareParams: prepareParams$s, - handleResponse: handleResponse$s - }); - - /* */ - function getOperation$r() { - return OPERATIONS.PNRemoveChannelsFromGroupOperation; - } - function validateParams$r(modules, incomingParams) { - var channels = incomingParams.channels, channelGroup = incomingParams.channelGroup; - var config = modules.config; - if (!channelGroup) - return 'Missing Channel Group'; - if (!channels || channels.length === 0) - return 'Missing Channels'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$p(modules, incomingParams) { - var channelGroup = incomingParams.channelGroup; - var config = modules.config; - return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup)); - } - function getRequestTimeout$r(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$r() { - return true; - } - function prepareParams$r(modules, incomingParams) { - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; - return { - remove: channels.join(','), - }; - } - function handleResponse$r() { - return {}; - } - - var removeChannelsChannelGroupConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$r, - validateParams: validateParams$r, - getURL: getURL$p, - getRequestTimeout: getRequestTimeout$r, - isAuthSupported: isAuthSupported$r, - prepareParams: prepareParams$r, - handleResponse: handleResponse$r - }); - - /* */ - function getOperation$q() { - return OPERATIONS.PNRemoveGroupOperation; - } - function validateParams$q(modules, incomingParams) { - var channelGroup = incomingParams.channelGroup; - var config = modules.config; - if (!channelGroup) - return 'Missing Channel Group'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$o(modules, incomingParams) { - var channelGroup = incomingParams.channelGroup; - var config = modules.config; - return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup), "/remove"); - } - function isAuthSupported$q() { - return true; - } - function getRequestTimeout$q(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function prepareParams$q() { - return {}; - } - function handleResponse$q() { - return {}; - } - - var deleteChannelGroupConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$q, - validateParams: validateParams$q, - getURL: getURL$o, - isAuthSupported: isAuthSupported$q, - getRequestTimeout: getRequestTimeout$q, - prepareParams: prepareParams$q, - handleResponse: handleResponse$q - }); - - /* */ - function getOperation$p() { - return OPERATIONS.PNChannelGroupsOperation; - } - function validateParams$p(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$n(modules) { - var config = modules.config; - return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group"); - } - function getRequestTimeout$p(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$p() { - return true; - } - function prepareParams$p() { - return {}; - } - function handleResponse$p(modules, serverResponse) { - return { - groups: serverResponse.payload.groups, - }; - } - - var listChannelGroupsConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$p, - validateParams: validateParams$p, - getURL: getURL$n, - getRequestTimeout: getRequestTimeout$p, - isAuthSupported: isAuthSupported$p, - prepareParams: prepareParams$p, - handleResponse: handleResponse$p - }); - - /* */ - function getOperation$o() { - return OPERATIONS.PNChannelsForGroupOperation; - } - function validateParams$o(modules, incomingParams) { - var channelGroup = incomingParams.channelGroup; - var config = modules.config; - if (!channelGroup) - return 'Missing Channel Group'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$m(modules, incomingParams) { - var channelGroup = incomingParams.channelGroup; - var config = modules.config; - return "/v1/channel-registration/sub-key/".concat(config.subscribeKey, "/channel-group/").concat(utils$5.encodeString(channelGroup)); - } - function getRequestTimeout$o(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$o() { - return true; - } - function prepareParams$o() { - return {}; - } - function handleResponse$o(modules, serverResponse) { - return { - channels: serverResponse.payload.channels, - }; - } - - var listChannelsInChannelGroupConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$o, - validateParams: validateParams$o, - getURL: getURL$m, - getRequestTimeout: getRequestTimeout$o, - isAuthSupported: isAuthSupported$o, - prepareParams: prepareParams$o, - handleResponse: handleResponse$o - }); - - /* */ - function getOperation$n() { - return OPERATIONS.PNPushNotificationEnabledChannelsOperation; - } - function validateParams$n(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway, channels = incomingParams.channels, topic = incomingParams.topic; - var config = modules.config; - if (!device) - return 'Missing Device ID (device)'; - if (!pushGateway) - return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; - if (pushGateway === 'apns2' && !topic) - return 'Missing APNS2 topic'; - if (!channels || channels.length === 0) - return 'Missing Channels'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$l(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway; - var config = modules.config; - if (pushGateway === 'apns2') { - return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device); - } - return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device); - } - function getRequestTimeout$n(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$n() { - return true; - } - function prepareParams$n(modules, incomingParams) { - var pushGateway = incomingParams.pushGateway, _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.environment, environment = _b === void 0 ? 'development' : _b, topic = incomingParams.topic; - var parameters = { type: pushGateway, add: channels.join(',') }; - if (pushGateway === 'apns2') { - parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); - delete parameters.type; - } - return parameters; - } - function handleResponse$n() { - return {}; - } - - var addPushChannelsConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$n, - validateParams: validateParams$n, - getURL: getURL$l, - getRequestTimeout: getRequestTimeout$n, - isAuthSupported: isAuthSupported$n, - prepareParams: prepareParams$n, - handleResponse: handleResponse$n - }); - - /* */ - function getOperation$m() { - return OPERATIONS.PNPushNotificationEnabledChannelsOperation; - } - function validateParams$m(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway, channels = incomingParams.channels, topic = incomingParams.topic; - var config = modules.config; - if (!device) - return 'Missing Device ID (device)'; - if (!pushGateway) - return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; - if (pushGateway === 'apns2' && !topic) - return 'Missing APNS2 topic'; - if (!channels || channels.length === 0) - return 'Missing Channels'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$k(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway; - var config = modules.config; - if (pushGateway === 'apns2') { - return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device); - } - return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device); - } - function getRequestTimeout$m(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$m() { - return true; - } - function prepareParams$m(modules, incomingParams) { - var pushGateway = incomingParams.pushGateway, _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.environment, environment = _b === void 0 ? 'development' : _b, topic = incomingParams.topic; - var parameters = { type: pushGateway, remove: channels.join(',') }; - if (pushGateway === 'apns2') { - parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); - delete parameters.type; - } - return parameters; - } - function handleResponse$m() { - return {}; - } - - var removePushChannelsConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$m, - validateParams: validateParams$m, - getURL: getURL$k, - getRequestTimeout: getRequestTimeout$m, - isAuthSupported: isAuthSupported$m, - prepareParams: prepareParams$m, - handleResponse: handleResponse$m - }); - - /* */ - function getOperation$l() { - return OPERATIONS.PNPushNotificationEnabledChannelsOperation; - } - function validateParams$l(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway, topic = incomingParams.topic; - var config = modules.config; - if (!device) - return 'Missing Device ID (device)'; - if (!pushGateway) - return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; - if (pushGateway === 'apns2' && !topic) - return 'Missing APNS2 topic'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$j(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway; - var config = modules.config; - if (pushGateway === 'apns2') { - return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device); - } - return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device); - } - function getRequestTimeout$l(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$l() { - return true; - } - function prepareParams$l(modules, incomingParams) { - var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic; - var parameters = { type: pushGateway }; - if (pushGateway === 'apns2') { - parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); - delete parameters.type; - } - return parameters; - } - function handleResponse$l(modules, serverResponse) { - return { channels: serverResponse }; - } - - var listPushChannelsConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$l, - validateParams: validateParams$l, - getURL: getURL$j, - getRequestTimeout: getRequestTimeout$l, - isAuthSupported: isAuthSupported$l, - prepareParams: prepareParams$l, - handleResponse: handleResponse$l - }); - - /* */ - function getOperation$k() { - return OPERATIONS.PNRemoveAllPushNotificationsOperation; - } - function validateParams$k(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway, topic = incomingParams.topic; - var config = modules.config; - if (!device) - return 'Missing Device ID (device)'; - if (!pushGateway) - return 'Missing GW Type (pushGateway: gcm, apns or apns2)'; - if (pushGateway === 'apns2' && !topic) - return 'Missing APNS2 topic'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$i(modules, incomingParams) { - var device = incomingParams.device, pushGateway = incomingParams.pushGateway; - var config = modules.config; - if (pushGateway === 'apns2') { - return "/v2/push/sub-key/".concat(config.subscribeKey, "/devices-apns2/").concat(device, "/remove"); - } - return "/v1/push/sub-key/".concat(config.subscribeKey, "/devices/").concat(device, "/remove"); - } - function getRequestTimeout$k(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$k() { - return true; - } - function prepareParams$k(modules, incomingParams) { - var pushGateway = incomingParams.pushGateway, _a = incomingParams.environment, environment = _a === void 0 ? 'development' : _a, topic = incomingParams.topic; - var parameters = { type: pushGateway }; - if (pushGateway === 'apns2') { - parameters = __assign(__assign({}, parameters), { environment: environment, topic: topic }); - delete parameters.type; - } - return parameters; - } - function handleResponse$k() { - return {}; - } - - var removeDevicePushConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$k, - validateParams: validateParams$k, - getURL: getURL$i, - getRequestTimeout: getRequestTimeout$k, - isAuthSupported: isAuthSupported$k, - prepareParams: prepareParams$k, - handleResponse: handleResponse$k - }); - - /* */ - function getOperation$j() { - return OPERATIONS.PNUnsubscribeOperation; - } - function validateParams$j(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$h(modules, incomingParams) { - var config = modules.config; - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; - var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; - return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/leave"); - } - function getRequestTimeout$j(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$j() { - return true; - } - function prepareParams$j(modules, incomingParams) { - var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a; - var params = {}; - if (channelGroups.length > 0) { - params['channel-group'] = channelGroups.join(','); - } - return params; - } - function handleResponse$j() { - return {}; - } - - var presenceLeaveEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$j, - validateParams: validateParams$j, - getURL: getURL$h, - getRequestTimeout: getRequestTimeout$j, - isAuthSupported: isAuthSupported$j, - prepareParams: prepareParams$j, - handleResponse: handleResponse$j - }); - - /* */ - function getOperation$i() { - return OPERATIONS.PNWhereNowOperation; - } - function validateParams$i(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$g(modules, incomingParams) { - var config = modules.config; - var _a = incomingParams.uuid, uuid = _a === void 0 ? config.UUID : _a; - return "/v2/presence/sub-key/".concat(config.subscribeKey, "/uuid/").concat(utils$5.encodeString(uuid)); - } - function getRequestTimeout$i(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$i() { - return true; - } - function prepareParams$i() { - return {}; - } - function handleResponse$i(modules, serverResponse) { - // This is a quick fix for when the server does not include a payload - // in where now responses - if (!serverResponse.payload) { - return { channels: [] }; - } - return { channels: serverResponse.payload.channels }; - } - - var presenceWhereNowEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$i, - validateParams: validateParams$i, - getURL: getURL$g, - getRequestTimeout: getRequestTimeout$i, - isAuthSupported: isAuthSupported$i, - prepareParams: prepareParams$i, - handleResponse: handleResponse$i - }); - - /* */ - function getOperation$h() { - return OPERATIONS.PNHeartbeatOperation; - } - function validateParams$h(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$f(modules, incomingParams) { - var config = modules.config; - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; - var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; - return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/heartbeat"); - } - function isAuthSupported$h() { - return true; - } - function getRequestTimeout$h(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function prepareParams$h(modules, incomingParams) { - var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, _b = incomingParams.state, state = _b === void 0 ? {} : _b; - var config = modules.config; - var params = {}; - if (channelGroups.length > 0) { - params['channel-group'] = channelGroups.join(','); - } - params.state = JSON.stringify(state); - params.heartbeat = config.getPresenceTimeout(); - return params; - } - function handleResponse$h() { - return {}; - } - - var presenceHeartbeatEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$h, - validateParams: validateParams$h, - getURL: getURL$f, - isAuthSupported: isAuthSupported$h, - getRequestTimeout: getRequestTimeout$h, - prepareParams: prepareParams$h, - handleResponse: handleResponse$h - }); - - /* */ - function getOperation$g() { - return OPERATIONS.PNGetStateOperation; - } - function validateParams$g(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$e(modules, incomingParams) { - var config = modules.config; - var _a = incomingParams.uuid, uuid = _a === void 0 ? config.UUID : _a, _b = incomingParams.channels, channels = _b === void 0 ? [] : _b; - var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; - return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/uuid/").concat(uuid); - } - function getRequestTimeout$g(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$g() { - return true; - } - function prepareParams$g(modules, incomingParams) { - var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a; - var params = {}; - if (channelGroups.length > 0) { - params['channel-group'] = channelGroups.join(','); - } - return params; - } - function handleResponse$g(modules, serverResponse, incomingParams) { - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b; - var channelsResponse = {}; - if (channels.length === 1 && channelGroups.length === 0) { - channelsResponse[channels[0]] = serverResponse.payload; - } - else { - channelsResponse = serverResponse.payload; - } - return { channels: channelsResponse }; - } - - var presenceGetStateConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$g, - validateParams: validateParams$g, - getURL: getURL$e, - getRequestTimeout: getRequestTimeout$g, - isAuthSupported: isAuthSupported$g, - prepareParams: prepareParams$g, - handleResponse: handleResponse$g - }); - - function getOperation$f() { - return OPERATIONS.PNSetStateOperation; - } - function validateParams$f(modules, incomingParams) { - var config = modules.config; - var state = incomingParams.state, _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b; - if (!state) - return 'Missing State'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (channels.length === 0 && channelGroups.length === 0) { - return 'Please provide a list of channels and/or channel-groups'; - } - } - function getURL$d(modules, incomingParams) { - var config = modules.config; - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; - var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; - return "/v2/presence/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels), "/uuid/").concat(utils$5.encodeString(config.UUID), "/data"); - } - function getRequestTimeout$f(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$f() { - return true; - } - function prepareParams$f(modules, incomingParams) { - var state = incomingParams.state, _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a; - var params = {}; - params.state = JSON.stringify(state); - if (channelGroups.length > 0) { - params['channel-group'] = channelGroups.join(','); - } - return params; - } - function handleResponse$f(modules, serverResponse) { - return { state: serverResponse.payload }; - } - - var presenceSetStateConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$f, - validateParams: validateParams$f, - getURL: getURL$d, - getRequestTimeout: getRequestTimeout$f, - isAuthSupported: isAuthSupported$f, - prepareParams: prepareParams$f, - handleResponse: handleResponse$f - }); - - /* */ - function getOperation$e() { - return OPERATIONS.PNHereNowOperation; - } - function validateParams$e(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$c(modules, incomingParams) { - var config = modules.config; - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b; - var baseURL = "/v2/presence/sub-key/".concat(config.subscribeKey); - if (channels.length > 0 || channelGroups.length > 0) { - var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; - baseURL += "/channel/".concat(utils$5.encodeString(stringifiedChannels)); - } - return baseURL; - } - function getRequestTimeout$e(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$e() { - return true; - } - function prepareParams$e(modules, incomingParams) { - var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, _b = incomingParams.includeUUIDs, includeUUIDs = _b === void 0 ? true : _b, _c = incomingParams.includeState, includeState = _c === void 0 ? false : _c, _d = incomingParams.queryParameters, queryParameters = _d === void 0 ? {} : _d; - var params = {}; - if (!includeUUIDs) - params.disable_uuids = 1; - if (includeState) - params.state = 1; - if (channelGroups.length > 0) { - params['channel-group'] = channelGroups.join(','); - } - params = __assign(__assign({}, params), queryParameters); - return params; - } - function handleResponse$e(modules, serverResponse, incomingParams) { - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = incomingParams.includeUUIDs, includeUUIDs = _c === void 0 ? true : _c, _d = incomingParams.includeState, includeState = _d === void 0 ? false : _d; - var prepareSingularChannel = function () { - var response = {}; - var occupantsList = []; - response.totalChannels = 1; - response.totalOccupancy = serverResponse.occupancy; - response.channels = {}; - response.channels[channels[0]] = { - occupants: occupantsList, - name: channels[0], - occupancy: serverResponse.occupancy, - }; - // We have had issues in the past with server returning responses - // that contain no uuids array - if (includeUUIDs && serverResponse.uuids) { - serverResponse.uuids.forEach(function (uuidEntry) { - if (includeState) { - occupantsList.push({ state: uuidEntry.state, uuid: uuidEntry.uuid }); - } - else { - occupantsList.push({ state: null, uuid: uuidEntry }); - } - }); - } - return response; - }; - var prepareMultipleChannel = function () { - var response = {}; - response.totalChannels = serverResponse.payload.total_channels; - response.totalOccupancy = serverResponse.payload.total_occupancy; - response.channels = {}; - Object.keys(serverResponse.payload.channels).forEach(function (channelName) { - var channelEntry = serverResponse.payload.channels[channelName]; - var occupantsList = []; - response.channels[channelName] = { - occupants: occupantsList, - name: channelName, - occupancy: channelEntry.occupancy, - }; - if (includeUUIDs) { - channelEntry.uuids.forEach(function (uuidEntry) { - if (includeState) { - occupantsList.push({ - state: uuidEntry.state, - uuid: uuidEntry.uuid, - }); - } - else { - occupantsList.push({ state: null, uuid: uuidEntry }); - } - }); - } - return response; - }); - return response; - }; - var response; - if (channels.length > 1 || channelGroups.length > 0 || (channelGroups.length === 0 && channels.length === 0)) { - response = prepareMultipleChannel(); - } - else { - response = prepareSingularChannel(); - } - return response; - } - function handleError(modules, params, status) { - if (status.statusCode === 402 && !this.getURL(modules, params).includes('channel')) { - status.errorData.message = - 'You have tried to perform a Global Here Now operation, ' + - 'your keyset configuration does not support that. Please provide a channel, ' + - 'or enable the Global Here Now feature from the Portal.'; - } - } - - var presenceHereNowConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$e, - validateParams: validateParams$e, - getURL: getURL$c, - getRequestTimeout: getRequestTimeout$e, - isAuthSupported: isAuthSupported$e, - prepareParams: prepareParams$e, - handleResponse: handleResponse$e, - handleError: handleError - }); - - /* */ - function getOperation$d() { - return OPERATIONS.PNAddMessageActionOperation; - } - function validateParams$d(_a, incomingParams) { - var config = _a.config; - var action = incomingParams.action, channel = incomingParams.channel, messageTimetoken = incomingParams.messageTimetoken; - if (!messageTimetoken) - return 'Missing message timetoken'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (!channel) - return 'Missing message channel'; - if (!action) - return 'Missing Action'; - if (!action.value) - return 'Missing Action.value'; - if (!action.type) - return 'Missing Action.type'; - if (action.type.length > 15) - return 'Action.type value exceed maximum length of 15'; - } - function usePost$2() { - return true; - } - function postURL$2(_a, incomingParams) { - var config = _a.config; - var channel = incomingParams.channel, messageTimetoken = incomingParams.messageTimetoken; - return "/v1/message-actions/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel), "/message/").concat(messageTimetoken); - } - function getRequestTimeout$d(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function getRequestHeaders() { - return { 'Content-Type': 'application/json' }; - } - function isAuthSupported$d() { - return true; - } - function prepareParams$d() { - return {}; - } - function postPayload$2(modules, incomingParams) { - return incomingParams.action; - } - function handleResponse$d(modules, addMessageActionResponse) { - return { data: addMessageActionResponse.data }; - } - - var addMessageActionEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$d, - validateParams: validateParams$d, - usePost: usePost$2, - postURL: postURL$2, - getRequestTimeout: getRequestTimeout$d, - getRequestHeaders: getRequestHeaders, - isAuthSupported: isAuthSupported$d, - prepareParams: prepareParams$d, - postPayload: postPayload$2, - handleResponse: handleResponse$d - }); - - /* */ - function getOperation$c() { - return OPERATIONS.PNRemoveMessageActionOperation; - } - function validateParams$c(_a, incomingParams) { - var config = _a.config; - var channel = incomingParams.channel, actionTimetoken = incomingParams.actionTimetoken, messageTimetoken = incomingParams.messageTimetoken; - if (!messageTimetoken) - return 'Missing message timetoken'; - if (!actionTimetoken) - return 'Missing action timetoken'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (!channel) - return 'Missing message channel'; - } - function useDelete$1() { - return true; - } - function getURL$b(_a, incomingParams) { - var config = _a.config; - var channel = incomingParams.channel, actionTimetoken = incomingParams.actionTimetoken, messageTimetoken = incomingParams.messageTimetoken; - return "/v1/message-actions/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel), "/message/").concat(messageTimetoken, "/action/").concat(actionTimetoken); - } - function getRequestTimeout$c(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$c() { - return true; - } - function prepareParams$c() { - return {}; - } - function handleResponse$c(modules, removeMessageActionResponse) { - return { data: removeMessageActionResponse.data }; - } - - var removeMessageActionEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$c, - validateParams: validateParams$c, - useDelete: useDelete$1, - getURL: getURL$b, - getRequestTimeout: getRequestTimeout$c, - isAuthSupported: isAuthSupported$c, - prepareParams: prepareParams$c, - handleResponse: handleResponse$c - }); - - /* */ - function getOperation$b() { - return OPERATIONS.PNGetMessageActionsOperation; - } - function validateParams$b(_a, incomingParams) { - var config = _a.config; - var channel = incomingParams.channel; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (!channel) - return 'Missing message channel'; - } - function getURL$a(_a, incomingParams) { - var config = _a.config; - var channel = incomingParams.channel; - return "/v1/message-actions/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel)); - } - function getRequestTimeout$b(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$b() { - return true; - } - function prepareParams$b(modules, incomingParams) { - var limit = incomingParams.limit, start = incomingParams.start, end = incomingParams.end; - var outgoingParams = {}; - if (limit) - outgoingParams.limit = limit; - if (start) - outgoingParams.start = start; - if (end) - outgoingParams.end = end; - return outgoingParams; - } - function handleResponse$b(modules, getMessageActionsResponse) { - /** @type GetMessageActionsResponse */ - var response = { data: getMessageActionsResponse.data, start: null, end: null }; - if (response.data.length) { - response.end = response.data[response.data.length - 1].actionTimetoken; - response.start = response.data[0].actionTimetoken; - } - return response; - } - - var getMessageActionEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$b, - validateParams: validateParams$b, - getURL: getURL$a, - getRequestTimeout: getRequestTimeout$b, - isAuthSupported: isAuthSupported$b, - prepareParams: prepareParams$b, - handleResponse: handleResponse$b - }); - - /** */ - var endpoint$j = { - getOperation: function () { return OPERATIONS.PNListFilesOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return "channel can't be empty"; - } - }, - getURL: function (_a, params) { - var config = _a.config; - return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/files"); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_, params) { - var outParams = {}; - if (params.limit) { - outParams.limit = params.limit; - } - if (params.next) { - outParams.next = params.next; - } - return outParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - next: response.next, - count: response.count, - }); }, - }; - - /** */ - var endpoint$i = { - getOperation: function () { return OPERATIONS.PNGenerateUploadUrlOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return "channel can't be empty"; - } - if (!(params === null || params === void 0 ? void 0 : params.name)) { - return "name can't be empty"; - } - }, - usePost: function () { return true; }, - postURL: function (_a, params) { - var config = _a.config; - return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/generate-upload-url"); - }, - postPayload: function (_, params) { return ({ - name: params.name, - }); }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function () { return ({}); }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - file_upload_request: response.file_upload_request, - }); }, - }; - - /** */ - var preparePayload = function (_a, payload) { - var crypto = _a.crypto, config = _a.config; - var stringifiedPayload = JSON.stringify(payload); - if (config.cipherKey) { - stringifiedPayload = crypto.encrypt(stringifiedPayload); - stringifiedPayload = JSON.stringify(stringifiedPayload); - } - return stringifiedPayload || ''; - }; - var endpoint$h = { - getOperation: function () { return OPERATIONS.PNPublishFileOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return "channel can't be empty"; - } - if (!(params === null || params === void 0 ? void 0 : params.fileId)) { - return "file id can't be empty"; - } - if (!(params === null || params === void 0 ? void 0 : params.fileName)) { - return "file name can't be empty"; - } - }, - getURL: function (modules, params) { - var _a = modules.config, publishKey = _a.publishKey, subscribeKey = _a.subscribeKey; - var message = { - message: params.message, - file: { - name: params.fileName, - id: params.fileId, - }, - }; - var payload = preparePayload(modules, message); - return "/v1/files/publish-file/".concat(publishKey, "/").concat(subscribeKey, "/0/").concat(utils$5.encodeString(params.channel), "/0/").concat(utils$5.encodeString(payload)); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_, params) { - var outParams = {}; - if (params.ttl) { - outParams.ttl = params.ttl; - } - if (params.storeInHistory !== undefined) { - outParams.store = params.storeInHistory ? '1' : '0'; - } - if (params.meta && typeof params.meta === 'object') { - outParams.meta = JSON.stringify(params.meta); - } - return outParams; - }, - handleResponse: function (_, response) { return ({ - timetoken: response['2'], - }); }, - }; - - var getErrorFromResponse = function (response) { - return new Promise(function (resolve) { - var result = ''; - response.on('data', function (data) { - result += data.toString('utf8'); - }); - response.on('end', function () { - resolve(result); - }); - }); - }; - var sendFile = function (_a) { - var _this = this; - var generateUploadUrl = _a.generateUploadUrl, publishFile = _a.publishFile, _b = _a.modules, PubNubFile = _b.PubNubFile, config = _b.config, cryptography = _b.cryptography, networking = _b.networking; - return function (_a) { - var channel = _a.channel, input = _a.file, message = _a.message, cipherKey = _a.cipherKey, meta = _a.meta, ttl = _a.ttl, storeInHistory = _a.storeInHistory; - return __awaiter(_this, void 0, void 0, function () { - var file, _b, _c, url, formFields, _d, id, name, formFieldsWithMimeType, result, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, e_1, errorBody, reason, retries, wasSuccessful, publishResult; - return __generator(this, function (_s) { - switch (_s.label) { - case 0: - if (!channel) { - throw new PubNubError('Validation failed, check status for details', createValidationError("channel can't be empty")); - } - if (!input) { - throw new PubNubError('Validation failed, check status for details', createValidationError("file can't be empty")); - } - file = PubNubFile.create(input); - return [4 /*yield*/, generateUploadUrl({ channel: channel, name: file.name })]; - case 1: - _b = _s.sent(), _c = _b.file_upload_request, url = _c.url, formFields = _c.form_fields, _d = _b.data, id = _d.id, name = _d.name; - if (!(PubNubFile.supportsEncryptFile && (cipherKey !== null && cipherKey !== void 0 ? cipherKey : config.cipherKey))) return [3 /*break*/, 3]; - return [4 /*yield*/, cryptography.encryptFile(cipherKey !== null && cipherKey !== void 0 ? cipherKey : config.cipherKey, file, PubNubFile)]; - case 2: - file = _s.sent(); - _s.label = 3; - case 3: - formFieldsWithMimeType = formFields; - if (file.mimeType) { - formFieldsWithMimeType = formFields.map(function (entry) { - if (entry.key === 'Content-Type') - return { key: entry.key, value: file.mimeType }; - return entry; - }); - } - _s.label = 4; - case 4: - _s.trys.push([4, 18, , 22]); - if (!(PubNubFile.supportsFileUri && input.uri)) return [3 /*break*/, 7]; - _f = (_e = networking).POSTFILE; - _g = [url, formFieldsWithMimeType]; - return [4 /*yield*/, file.toFileUri()]; - case 5: return [4 /*yield*/, _f.apply(_e, _g.concat([_s.sent()]))]; - case 6: - result = _s.sent(); - return [3 /*break*/, 17]; - case 7: - if (!PubNubFile.supportsFile) return [3 /*break*/, 10]; - _j = (_h = networking).POSTFILE; - _k = [url, formFieldsWithMimeType]; - return [4 /*yield*/, file.toFile()]; - case 8: return [4 /*yield*/, _j.apply(_h, _k.concat([_s.sent()]))]; - case 9: - result = _s.sent(); - return [3 /*break*/, 17]; - case 10: - if (!PubNubFile.supportsBuffer) return [3 /*break*/, 13]; - _m = (_l = networking).POSTFILE; - _o = [url, formFieldsWithMimeType]; - return [4 /*yield*/, file.toBuffer()]; - case 11: return [4 /*yield*/, _m.apply(_l, _o.concat([_s.sent()]))]; - case 12: - result = _s.sent(); - return [3 /*break*/, 17]; - case 13: - if (!PubNubFile.supportsBlob) return [3 /*break*/, 16]; - _q = (_p = networking).POSTFILE; - _r = [url, formFieldsWithMimeType]; - return [4 /*yield*/, file.toBlob()]; - case 14: return [4 /*yield*/, _q.apply(_p, _r.concat([_s.sent()]))]; - case 15: - result = _s.sent(); - return [3 /*break*/, 17]; - case 16: throw new Error('Unsupported environment'); - case 17: return [3 /*break*/, 22]; - case 18: - e_1 = _s.sent(); - if (!e_1.response) return [3 /*break*/, 20]; - return [4 /*yield*/, getErrorFromResponse(e_1.response)]; - case 19: - errorBody = _s.sent(); - reason = /(.*)<\/Message>/gi.exec(errorBody); - throw new PubNubError(reason ? "Upload to bucket failed: ".concat(reason[1]) : 'Upload to bucket failed.', e_1); - case 20: throw new PubNubError('Upload to bucket failed.', e_1); - case 21: return [3 /*break*/, 22]; - case 22: - if (result.status !== 204) { - throw new PubNubError('Upload to bucket was unsuccessful', result); - } - retries = config.fileUploadPublishRetryLimit; - wasSuccessful = false; - publishResult = { timetoken: '0' }; - _s.label = 23; - case 23: - _s.trys.push([23, 25, , 26]); - return [4 /*yield*/, publishFile({ - channel: channel, - message: message, - fileId: id, - fileName: name, - meta: meta, - storeInHistory: storeInHistory, - ttl: ttl, - })]; - case 24: - /* eslint-disable-next-line no-await-in-loop */ - publishResult = _s.sent(); - wasSuccessful = true; - return [3 /*break*/, 26]; - case 25: - _s.sent(); - retries -= 1; - return [3 /*break*/, 26]; - case 26: - if (!wasSuccessful && retries > 0) return [3 /*break*/, 23]; - _s.label = 27; - case 27: - if (!wasSuccessful) { - throw new PubNubError('Publish failed. You may want to execute that operation manually using pubnub.publishFile', { - channel: channel, - id: id, - name: name, - }); - } - else { - return [2 /*return*/, { - timetoken: publishResult.timetoken, - id: id, - name: name, - }]; - } - } - }); - }); - }; - }; - var sendFileFunction = (function (deps) { - var f = sendFile(deps); - return function (params, cb) { - var resultP = f(params); - if (typeof cb === 'function') { - resultP.then(function (result) { return cb(null, result); }).catch(function (error) { return cb(error, null); }); - return resultP; - } - return resultP; - }; - }); - - /** */ - var getFileUrlFunction = (function (modules, _a) { - var channel = _a.channel, id = _a.id, name = _a.name; - var config = modules.config, networking = modules.networking, tokenManager = modules.tokenManager; - if (!channel) { - throw new PubNubError('Validation failed, check status for details', createValidationError("channel can't be empty")); - } - if (!id) { - throw new PubNubError('Validation failed, check status for details', createValidationError("file id can't be empty")); - } - if (!name) { - throw new PubNubError('Validation failed, check status for details', createValidationError("file name can't be empty")); - } - var url = "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(channel), "/files/").concat(id, "/").concat(name); - var params = {}; - params.uuid = config.getUUID(); - params.pnsdk = generatePNSDK(config); - var tokenOrKey = tokenManager.getToken() || config.getAuthKey(); - if (tokenOrKey) { - params.auth = tokenOrKey; - } - if (config.secretKey) { - signRequest(modules, url, params, {}, { - getOperation: function () { return 'PubNubGetFileUrlOperation'; }, - }); - } - var queryParams = Object.keys(params) - .map(function (key) { return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(params[key])); }) - .join('&'); - if (queryParams !== '') { - return "".concat(networking.getStandardOrigin()).concat(url, "?").concat(queryParams); - } - return "".concat(networking.getStandardOrigin()).concat(url); - }); - - /** */ - var endpoint$g = { - getOperation: function () { return OPERATIONS.PNDownloadFileOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return "channel can't be empty"; - } - if (!(params === null || params === void 0 ? void 0 : params.name)) { - return "name can't be empty"; - } - if (!(params === null || params === void 0 ? void 0 : params.id)) { - return "id can't be empty"; - } - }, - useGetFile: function () { return true; }, - getFileURL: function (_a, params) { - var config = _a.config; - return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/files/").concat(params.id, "/").concat(params.name); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - ignoreBody: function () { return true; }, - forceBuffered: function () { return true; }, - prepareParams: function () { return ({}); }, - handleResponse: function (_a, res, params) { - var PubNubFile = _a.PubNubFile, config = _a.config, cryptography = _a.cryptography; - return __awaiter(void 0, void 0, void 0, function () { - var body; - var _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { - case 0: - body = res.response.body; - if (!(PubNubFile.supportsEncryptFile && ((_b = params.cipherKey) !== null && _b !== void 0 ? _b : config.cipherKey))) return [3 /*break*/, 2]; - return [4 /*yield*/, cryptography.decrypt((_c = params.cipherKey) !== null && _c !== void 0 ? _c : config.cipherKey, body)]; - case 1: - body = _e.sent(); - _e.label = 2; - case 2: return [2 /*return*/, PubNubFile.create({ - data: body, - name: (_d = res.response.name) !== null && _d !== void 0 ? _d : params.name, - mimeType: res.response.type, - })]; - } - }); - }); - }, - }; - - /** */ - var endpoint$f = { - getOperation: function () { return OPERATIONS.PNListFilesOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return "channel can't be empty"; - } - if (!(params === null || params === void 0 ? void 0 : params.id)) { - return "file id can't be empty"; - } - if (!(params === null || params === void 0 ? void 0 : params.name)) { - return "file name can't be empty"; - } - }, - useDelete: function () { return true; }, - getURL: function (_a, params) { - var config = _a.config; - return "/v1/files/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/files/").concat(params.id, "/").concat(params.name); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function () { return ({}); }, - handleResponse: function (_, response) { return ({ - status: response.status, - }); }, - }; - - var endpoint$e = { - getOperation: function () { return OPERATIONS.PNGetAllUUIDMetadataOperation; }, - validateParams: function () { - // No required parameters. - }, - getURL: function (_a) { - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/uuids"); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_modules, params) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; - var queryParams = {}; - queryParams.include = ['status', 'type']; - if (params === null || params === void 0 ? void 0 : params.include) { - if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { - queryParams.include.push('custom'); - } - } - queryParams.include = queryParams.include.join(','); - if ((_b = params === null || params === void 0 ? void 0 : params.include) === null || _b === void 0 ? void 0 : _b.totalCount) { - queryParams.count = (_c = params.include) === null || _c === void 0 ? void 0 : _c.totalCount; - } - if ((_d = params === null || params === void 0 ? void 0 : params.page) === null || _d === void 0 ? void 0 : _d.next) { - queryParams.start = (_e = params.page) === null || _e === void 0 ? void 0 : _e.next; - } - if ((_f = params === null || params === void 0 ? void 0 : params.page) === null || _f === void 0 ? void 0 : _f.prev) { - queryParams.end = (_g = params.page) === null || _g === void 0 ? void 0 : _g.prev; - } - if (params === null || params === void 0 ? void 0 : params.filter) { - queryParams.filter = params.filter; - } - queryParams.limit = (_h = params === null || params === void 0 ? void 0 : params.limit) !== null && _h !== void 0 ? _h : 100; - if (params === null || params === void 0 ? void 0 : params.sort) { - queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { - var _b = __read(_a, 2), key = _b[0], value = _b[1]; - if (value === 'asc' || value === 'desc') { - return "".concat(key, ":").concat(value); - } - return key; - }); - } - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - totalCount: response.totalCount, - next: response.next, - prev: response.prev, - }); }, - }; - - /** */ - var endpoint$d = { - getOperation: function () { return OPERATIONS.PNGetUUIDMetadataOperation; }, - validateParams: function () { - // No required parameters. - }, - getURL: function (_a, params) { - var _b; - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID())); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_a, params) { - var _b, _c; - var config = _a.config; - var queryParams = {}; - queryParams.uuid = (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID(); - queryParams.include = ['status', 'type', 'custom']; - if (params === null || params === void 0 ? void 0 : params.include) { - if (((_c = params.include) === null || _c === void 0 ? void 0 : _c.customFields) === false) { - queryParams.include.pop(); - } - } - queryParams.include = queryParams.include.join(','); - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - }); }, - }; - - /** */ - var endpoint$c = { - getOperation: function () { return OPERATIONS.PNSetUUIDMetadataOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.data)) { - return 'Data cannot be empty'; - } - }, - usePatch: function () { return true; }, - patchURL: function (_a, params) { - var _b; - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params.uuid) !== null && _b !== void 0 ? _b : config.getUUID())); - }, - patchPayload: function (_, params) { return params.data; }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_a, params) { - var _b, _c; - var config = _a.config; - var queryParams = {}; - queryParams.uuid = (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID(); - queryParams.include = ['status', 'type', 'custom']; - if (params === null || params === void 0 ? void 0 : params.include) { - if (((_c = params.include) === null || _c === void 0 ? void 0 : _c.customFields) === false) { - queryParams.include.pop(); - } - } - queryParams.include = queryParams.include.join(','); - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - }); }, - }; - - /** */ - var endpoint$b = { - getOperation: function () { return OPERATIONS.PNRemoveUUIDMetadataOperation; }, - validateParams: function () { - // No required parameters. - }, - getURL: function (_a, params) { - var _b; - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID())); - }, - useDelete: function () { return true; }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_a, params) { - var _b; - var config = _a.config; - return ({ - uuid: (_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID(), - }); - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - }); }, - }; - - var endpoint$a = { - getOperation: function () { return OPERATIONS.PNGetAllChannelMetadataOperation; }, - validateParams: function () { - // No required parameters. - }, - getURL: function (_a) { - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/channels"); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_modules, params) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; - var queryParams = {}; - queryParams.include = ['status', 'type']; - if (params === null || params === void 0 ? void 0 : params.include) { - if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { - queryParams.include.push('custom'); - } - } - queryParams.include = queryParams.include.join(','); - if ((_b = params === null || params === void 0 ? void 0 : params.include) === null || _b === void 0 ? void 0 : _b.totalCount) { - queryParams.count = (_c = params.include) === null || _c === void 0 ? void 0 : _c.totalCount; - } - if ((_d = params === null || params === void 0 ? void 0 : params.page) === null || _d === void 0 ? void 0 : _d.next) { - queryParams.start = (_e = params.page) === null || _e === void 0 ? void 0 : _e.next; - } - if ((_f = params === null || params === void 0 ? void 0 : params.page) === null || _f === void 0 ? void 0 : _f.prev) { - queryParams.end = (_g = params.page) === null || _g === void 0 ? void 0 : _g.prev; - } - if (params === null || params === void 0 ? void 0 : params.filter) { - queryParams.filter = params.filter; - } - queryParams.limit = (_h = params === null || params === void 0 ? void 0 : params.limit) !== null && _h !== void 0 ? _h : 100; - if (params === null || params === void 0 ? void 0 : params.sort) { - queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { - var _b = __read(_a, 2), key = _b[0], value = _b[1]; - if (value === 'asc' || value === 'desc') { - return "".concat(key, ":").concat(value); - } - return key; - }); - } - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - totalCount: response.totalCount, - prev: response.prev, - next: response.next, - }); }, - }; - - var endpoint$9 = { - getOperation: function () { return OPERATIONS.PNGetChannelMetadataOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return 'Channel cannot be empty'; - } - }, - getURL: function (_a, params) { - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel)); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_, params) { - var _a; - var queryParams = {}; - queryParams.include = ['status', 'type', 'custom']; - if (params === null || params === void 0 ? void 0 : params.include) { - if (((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) === false) { - queryParams.include.pop(); - } - } - queryParams.include = queryParams.include.join(','); - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - }); }, - }; - - /** */ - var endpoint$8 = { - getOperation: function () { return OPERATIONS.PNSetChannelMetadataOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return 'Channel cannot be empty'; - } - if (!(params === null || params === void 0 ? void 0 : params.data)) { - return 'Data cannot be empty'; - } - }, - usePatch: function () { return true; }, - patchURL: function (_a, params) { - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel)); - }, - patchPayload: function (_, params) { return params.data; }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_, params) { - var _a; - var queryParams = {}; - queryParams.include = ['status', 'type', 'custom']; - if (params === null || params === void 0 ? void 0 : params.include) { - if (((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) === false) { - queryParams.include.pop(); - } - } - queryParams.include = queryParams.include.join(','); - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - }); }, - }; - - /** */ - var endpoint$7 = { - getOperation: function () { return OPERATIONS.PNRemoveChannelMetadataOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return 'Channel cannot be empty'; - } - }, - getURL: function (_a, params) { - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel)); - }, - useDelete: function () { return true; }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function () { return ({}); }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - }); }, - }; - - /** */ - var endpoint$6 = { - getOperation: function () { return OPERATIONS.PNGetMembersOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return 'UUID cannot be empty'; - } - }, - getURL: function (_a, params) { - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/uuids"); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_modules, params) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; - var queryParams = {}; - queryParams.include = ['uuid.status', 'uuid.type', 'type']; - if (params === null || params === void 0 ? void 0 : params.include) { - if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { - queryParams.include.push('custom'); - } - if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customUUIDFields) { - queryParams.include.push('uuid.custom'); - } - if ((_d = (_c = params.include) === null || _c === void 0 ? void 0 : _c.UUIDFields) !== null && _d !== void 0 ? _d : true) { - queryParams.include.push('uuid'); - } - } - queryParams.include = queryParams.include.join(','); - if ((_e = params === null || params === void 0 ? void 0 : params.include) === null || _e === void 0 ? void 0 : _e.totalCount) { - queryParams.count = (_f = params.include) === null || _f === void 0 ? void 0 : _f.totalCount; - } - if ((_g = params === null || params === void 0 ? void 0 : params.page) === null || _g === void 0 ? void 0 : _g.next) { - queryParams.start = (_h = params.page) === null || _h === void 0 ? void 0 : _h.next; - } - if ((_j = params === null || params === void 0 ? void 0 : params.page) === null || _j === void 0 ? void 0 : _j.prev) { - queryParams.end = (_k = params.page) === null || _k === void 0 ? void 0 : _k.prev; - } - if (params === null || params === void 0 ? void 0 : params.filter) { - queryParams.filter = params.filter; - } - queryParams.limit = (_l = params === null || params === void 0 ? void 0 : params.limit) !== null && _l !== void 0 ? _l : 100; - if (params === null || params === void 0 ? void 0 : params.sort) { - queryParams.sort = Object.entries((_m = params.sort) !== null && _m !== void 0 ? _m : {}).map(function (_a) { - var _b = __read(_a, 2), key = _b[0], value = _b[1]; - if (value === 'asc' || value === 'desc') { - return "".concat(key, ":").concat(value); - } - return key; - }); - } - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - totalCount: response.totalCount, - prev: response.prev, - next: response.next, - }); }, - }; - - var endpoint$5 = { - getOperation: function () { return OPERATIONS.PNSetMembersOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channel)) { - return 'Channel cannot be empty'; - } - if (!(params === null || params === void 0 ? void 0 : params.uuids) || (params === null || params === void 0 ? void 0 : params.uuids.length) === 0) { - return 'UUIDs cannot be empty'; - } - }, - usePatch: function () { return true; }, - patchURL: function (_a, params) { - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/channels/").concat(utils$5.encodeString(params.channel), "/uuids"); - }, - patchPayload: function (_, params) { - var _a; - return (_a = { - set: [], - delete: [] - }, - _a[params.type] = params.uuids.map(function (uuid) { - if (typeof uuid === 'string') { - return { - uuid: { - id: uuid, - }, - }; - } - return { - uuid: { id: uuid.id }, - custom: uuid.custom, - status: uuid.status, - }; - }), - _a); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_modules, params) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; - var queryParams = {}; - queryParams.include = ['uuid.status', 'uuid.type', 'type']; - if (params === null || params === void 0 ? void 0 : params.include) { - if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { - queryParams.include.push('custom'); - } - if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customUUIDFields) { - queryParams.include.push('uuid.custom'); - } - if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.UUIDFields) { - queryParams.include.push('uuid'); - } - } - queryParams.include = queryParams.include.join(','); - if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) { - queryParams.count = true; - } - if ((_e = params === null || params === void 0 ? void 0 : params.page) === null || _e === void 0 ? void 0 : _e.next) { - queryParams.start = (_f = params.page) === null || _f === void 0 ? void 0 : _f.next; - } - if ((_g = params === null || params === void 0 ? void 0 : params.page) === null || _g === void 0 ? void 0 : _g.prev) { - queryParams.end = (_h = params.page) === null || _h === void 0 ? void 0 : _h.prev; - } - if (params === null || params === void 0 ? void 0 : params.filter) { - queryParams.filter = params.filter; - } - if (params.limit != null) { - queryParams.limit = params.limit; - } - if (params === null || params === void 0 ? void 0 : params.sort) { - queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { - var _b = __read(_a, 2), key = _b[0], value = _b[1]; - if (value === 'asc' || value === 'desc') { - return "".concat(key, ":").concat(value); - } - return key; - }); - } - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - totalCount: response.totalCount, - prev: response.prev, - next: response.next, - }); }, - }; - - var endpoint$4 = { - getOperation: function () { return OPERATIONS.PNGetMembershipsOperation; }, - validateParams: function () { - // No required parameters. - }, - getURL: function (_a, params) { - var _b; - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params === null || params === void 0 ? void 0 : params.uuid) !== null && _b !== void 0 ? _b : config.getUUID()), "/channels"); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_modules, params) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; - var queryParams = {}; - queryParams.include = ['channel.status', 'channel.type', 'status']; - if (params === null || params === void 0 ? void 0 : params.include) { - if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { - queryParams.include.push('custom'); - } - if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customChannelFields) { - queryParams.include.push('channel.custom'); - } - if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.channelFields) { - queryParams.include.push('channel'); - } - } - queryParams.include = queryParams.include.join(','); - if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) { - queryParams.count = (_e = params.include) === null || _e === void 0 ? void 0 : _e.totalCount; - } - if ((_f = params === null || params === void 0 ? void 0 : params.page) === null || _f === void 0 ? void 0 : _f.next) { - queryParams.start = (_g = params.page) === null || _g === void 0 ? void 0 : _g.next; - } - if ((_h = params === null || params === void 0 ? void 0 : params.page) === null || _h === void 0 ? void 0 : _h.prev) { - queryParams.end = (_j = params.page) === null || _j === void 0 ? void 0 : _j.prev; - } - if (params === null || params === void 0 ? void 0 : params.filter) { - queryParams.filter = params.filter; - } - queryParams.limit = (_k = params === null || params === void 0 ? void 0 : params.limit) !== null && _k !== void 0 ? _k : 100; - if (params === null || params === void 0 ? void 0 : params.sort) { - queryParams.sort = Object.entries((_l = params.sort) !== null && _l !== void 0 ? _l : {}).map(function (_a) { - var _b = __read(_a, 2), key = _b[0], value = _b[1]; - if (value === 'asc' || value === 'desc') { - return "".concat(key, ":").concat(value); - } - return key; - }); - } - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - totalCount: response.totalCount, - prev: response.prev, - next: response.next, - }); }, - }; - - /** */ - var endpoint$3 = { - getOperation: function () { return OPERATIONS.PNSetMembershipsOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channels) || (params === null || params === void 0 ? void 0 : params.channels.length) === 0) { - return 'Channels cannot be empty'; - } - }, - usePatch: function () { return true; }, - patchURL: function (_a, params) { - var _b; - var config = _a.config; - return "/v2/objects/".concat(config.subscribeKey, "/uuids/").concat(utils$5.encodeString((_b = params.uuid) !== null && _b !== void 0 ? _b : config.getUUID()), "/channels"); - }, - patchPayload: function (_, params) { - var _a; - return (_a = { - set: [], - delete: [] - }, - _a[params.type] = params.channels.map(function (channel) { - if (typeof channel === 'string') { - return { - channel: { - id: channel, - }, - }; - } - return { - channel: { id: channel.id }, - custom: channel.custom, - status: channel.status, - }; - }), - _a); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_modules, params) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; - var queryParams = {}; - queryParams.include = ['channel.status', 'channel.type', 'status']; - if (params === null || params === void 0 ? void 0 : params.include) { - if ((_a = params.include) === null || _a === void 0 ? void 0 : _a.customFields) { - queryParams.include.push('custom'); - } - if ((_b = params.include) === null || _b === void 0 ? void 0 : _b.customChannelFields) { - queryParams.include.push('channel.custom'); - } - if ((_c = params.include) === null || _c === void 0 ? void 0 : _c.channelFields) { - queryParams.include.push('channel'); - } - } - queryParams.include = queryParams.include.join(','); - if ((_d = params === null || params === void 0 ? void 0 : params.include) === null || _d === void 0 ? void 0 : _d.totalCount) { - queryParams.count = true; - } - if ((_e = params === null || params === void 0 ? void 0 : params.page) === null || _e === void 0 ? void 0 : _e.next) { - queryParams.start = (_f = params.page) === null || _f === void 0 ? void 0 : _f.next; - } - if ((_g = params === null || params === void 0 ? void 0 : params.page) === null || _g === void 0 ? void 0 : _g.prev) { - queryParams.end = (_h = params.page) === null || _h === void 0 ? void 0 : _h.prev; - } - if (params === null || params === void 0 ? void 0 : params.filter) { - queryParams.filter = params.filter; - } - if (params.limit != null) { - queryParams.limit = params.limit; - } - if (params === null || params === void 0 ? void 0 : params.sort) { - queryParams.sort = Object.entries((_j = params.sort) !== null && _j !== void 0 ? _j : {}).map(function (_a) { - var _b = __read(_a, 2), key = _b[0], value = _b[1]; - if (value === 'asc' || value === 'desc') { - return "".concat(key, ":").concat(value); - } - return key; - }); - } - return queryParams; - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - totalCount: response.totalCount, - prev: response.prev, - next: response.next, - }); }, - }; - - /* */ - function getOperation$a() { - return OPERATIONS.PNAccessManagerAudit; - } - function validateParams$a(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$9(modules) { - var config = modules.config; - return "/v2/auth/audit/sub-key/".concat(config.subscribeKey); - } - function getRequestTimeout$a(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$a() { - return false; - } - function prepareParams$a(modules, incomingParams) { - var channel = incomingParams.channel, channelGroup = incomingParams.channelGroup, _a = incomingParams.authKeys, authKeys = _a === void 0 ? [] : _a; - var params = {}; - if (channel) { - params.channel = channel; - } - if (channelGroup) { - params['channel-group'] = channelGroup; - } - if (authKeys.length > 0) { - params.auth = authKeys.join(','); - } - return params; - } - function handleResponse$a(modules, serverResponse) { - return serverResponse.payload; - } - - var auditEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$a, - validateParams: validateParams$a, - getURL: getURL$9, - getRequestTimeout: getRequestTimeout$a, - isAuthSupported: isAuthSupported$a, - prepareParams: prepareParams$a, - handleResponse: handleResponse$a - }); - - /* */ - function getOperation$9() { - return OPERATIONS.PNAccessManagerGrant; - } - function validateParams$9(modules, incomingParams) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (!config.publishKey) - return 'Missing Publish Key'; - if (!config.secretKey) - return 'Missing Secret Key'; - if (incomingParams.uuids != null && !incomingParams.authKeys) { - return 'authKeys are required for grant request on uuids'; - } - if (incomingParams.uuids != null && (incomingParams.channels != null || incomingParams.channelGroups != null)) { - return 'Both channel/channelgroup and uuid cannot be used in the same request'; - } - } - function getURL$8(modules) { - var config = modules.config; - return "/v2/auth/grant/sub-key/".concat(config.subscribeKey); - } - function getRequestTimeout$9(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$9() { - return false; - } - function prepareParams$9(modules, incomingParams) { - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b, _c = incomingParams.uuids, uuids = _c === void 0 ? [] : _c, ttl = incomingParams.ttl, _d = incomingParams.read, read = _d === void 0 ? false : _d, _e = incomingParams.write, write = _e === void 0 ? false : _e, _f = incomingParams.manage, manage = _f === void 0 ? false : _f, _g = incomingParams.get, get = _g === void 0 ? false : _g, _h = incomingParams.join, join = _h === void 0 ? false : _h, _j = incomingParams.update, update = _j === void 0 ? false : _j, _k = incomingParams.authKeys, authKeys = _k === void 0 ? [] : _k; - var deleteParam = incomingParams.delete; - var params = {}; - params.r = read ? '1' : '0'; - params.w = write ? '1' : '0'; - params.m = manage ? '1' : '0'; - params.d = deleteParam ? '1' : '0'; - params.g = get ? '1' : '0'; - params.j = join ? '1' : '0'; - params.u = update ? '1' : '0'; - if (channels.length > 0) { - params.channel = channels.join(','); - } - if (channelGroups.length > 0) { - params['channel-group'] = channelGroups.join(','); - } - if (authKeys.length > 0) { - params.auth = authKeys.join(','); - } - if (uuids.length > 0) { - params['target-uuid'] = uuids.join(','); - } - if (ttl || ttl === 0) { - params.ttl = ttl; - } - return params; - } - function handleResponse$9() { - return {}; - } - - var grantEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$9, - validateParams: validateParams$9, - getURL: getURL$8, - getRequestTimeout: getRequestTimeout$9, - isAuthSupported: isAuthSupported$9, - prepareParams: prepareParams$9, - handleResponse: handleResponse$9 - }); - - function getOperation$8() { - return OPERATIONS.PNAccessManagerGrantToken; - } - function hasVspTerms(incomingParams) { - var _a, _b, _c, _d; - var hasAuthorizedUserId = (incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.authorizedUserId) !== undefined; - var hasUserResources = ((_a = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _a === void 0 ? void 0 : _a.users) !== undefined; - var hasSpaceResources = ((_b = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _b === void 0 ? void 0 : _b.spaces) !== undefined; - var hasUserPatterns = ((_c = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _c === void 0 ? void 0 : _c.users) !== undefined; - var hasSpacePatterns = ((_d = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _d === void 0 ? void 0 : _d.spaces) !== undefined; - return hasUserPatterns || hasUserResources || hasSpacePatterns || hasSpaceResources || hasAuthorizedUserId; - } - function extractPermissions(permissions) { - var permissionsResult = 0; - if (permissions.join) { - permissionsResult |= 128; - } - if (permissions.update) { - permissionsResult |= 64; - } - if (permissions.get) { - permissionsResult |= 32; - } - if (permissions.delete) { - permissionsResult |= 8; - } - if (permissions.manage) { - permissionsResult |= 4; - } - if (permissions.write) { - permissionsResult |= 2; - } - if (permissions.read) { - permissionsResult |= 1; - } - return permissionsResult; - } - function prepareMessagePayloadVsp(_modules, _a) { - var ttl = _a.ttl, resources = _a.resources, patterns = _a.patterns, meta = _a.meta, authorizedUserId = _a.authorizedUserId; - var params = { - ttl: 0, - permissions: { - resources: { - channels: {}, - groups: {}, - uuids: {}, - users: {}, - spaces: {}, // not used, needed for api backward compatibility - }, - patterns: { - channels: {}, - groups: {}, - uuids: {}, - users: {}, - spaces: {}, // not used, needed for api backward compatibility - }, - meta: {}, - }, - }; - if (resources) { - var users_1 = resources.users, spaces_1 = resources.spaces, groups_1 = resources.groups; - if (users_1) { - Object.keys(users_1).forEach(function (userID) { - params.permissions.resources.uuids[userID] = extractPermissions(users_1[userID]); - }); - } - if (spaces_1) { - Object.keys(spaces_1).forEach(function (spaceId) { - params.permissions.resources.channels[spaceId] = extractPermissions(spaces_1[spaceId]); - }); - } - if (groups_1) { - Object.keys(groups_1).forEach(function (group) { - params.permissions.resources.groups[group] = extractPermissions(groups_1[group]); - }); - } - } - if (patterns) { - var users_2 = patterns.users, spaces_2 = patterns.spaces, groups_2 = patterns.groups; - if (users_2) { - Object.keys(users_2).forEach(function (userId) { - params.permissions.patterns.uuids[userId] = extractPermissions(users_2[userId]); - }); - } - if (spaces_2) { - Object.keys(spaces_2).forEach(function (spaceId) { - params.permissions.patterns.channels[spaceId] = extractPermissions(spaces_2[spaceId]); - }); - } - if (groups_2) { - Object.keys(groups_2).forEach(function (group) { - params.permissions.patterns.groups[group] = extractPermissions(groups_2[group]); - }); - } - } - if (ttl || ttl === 0) { - params.ttl = ttl; - } - if (meta) { - params.permissions.meta = meta; - } - if (authorizedUserId) { - params.permissions.uuid = "".concat(authorizedUserId); // ensure this is a string - } - return params; - } - function prepareMessagePayload$2(_modules, incomingParams) { - if (hasVspTerms(incomingParams)) { - return prepareMessagePayloadVsp(_modules, incomingParams); - } - var ttl = incomingParams.ttl, resources = incomingParams.resources, patterns = incomingParams.patterns, meta = incomingParams.meta, authorized_uuid = incomingParams.authorized_uuid; - var params = { - ttl: 0, - permissions: { - resources: { - channels: {}, - groups: {}, - uuids: {}, - users: {}, - spaces: {}, // not used, needed for api backward compatibility - }, - patterns: { - channels: {}, - groups: {}, - uuids: {}, - users: {}, - spaces: {}, // not used, needed for api backward compatibility - }, - meta: {}, - }, - }; - if (resources) { - var uuids_1 = resources.uuids, channels_1 = resources.channels, groups_3 = resources.groups; - if (uuids_1) { - Object.keys(uuids_1).forEach(function (uuid) { - params.permissions.resources.uuids[uuid] = extractPermissions(uuids_1[uuid]); - }); - } - if (channels_1) { - Object.keys(channels_1).forEach(function (channel) { - params.permissions.resources.channels[channel] = extractPermissions(channels_1[channel]); - }); - } - if (groups_3) { - Object.keys(groups_3).forEach(function (group) { - params.permissions.resources.groups[group] = extractPermissions(groups_3[group]); - }); - } - } - if (patterns) { - var uuids_2 = patterns.uuids, channels_2 = patterns.channels, groups_4 = patterns.groups; - if (uuids_2) { - Object.keys(uuids_2).forEach(function (uuid) { - params.permissions.patterns.uuids[uuid] = extractPermissions(uuids_2[uuid]); - }); - } - if (channels_2) { - Object.keys(channels_2).forEach(function (channel) { - params.permissions.patterns.channels[channel] = extractPermissions(channels_2[channel]); - }); - } - if (groups_4) { - Object.keys(groups_4).forEach(function (group) { - params.permissions.patterns.groups[group] = extractPermissions(groups_4[group]); - }); - } - } - if (ttl || ttl === 0) { - params.ttl = ttl; - } - if (meta) { - params.permissions.meta = meta; - } - if (authorized_uuid) { - params.permissions.uuid = "".concat(authorized_uuid); // ensure this is a string - } - return params; - } - function validateParams$8(modules, incomingParams) { - var _a, _b, _c, _d, _e, _f; - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (!config.publishKey) - return 'Missing Publish Key'; - if (!config.secretKey) - return 'Missing Secret Key'; - if (!incomingParams.resources && !incomingParams.patterns) - return 'Missing either Resources or Patterns.'; - var hasAuthorizedUuid = (incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.authorized_uuid) !== undefined; - var hasUuidResources = ((_a = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _a === void 0 ? void 0 : _a.uuids) !== undefined; - var hasChannelResources = ((_b = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _b === void 0 ? void 0 : _b.channels) !== undefined; - var hasGroupResources = ((_c = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.resources) === null || _c === void 0 ? void 0 : _c.groups) !== undefined; - var hasUuidPatterns = ((_d = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _d === void 0 ? void 0 : _d.uuids) !== undefined; - var hasChannelPatterns = ((_e = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _e === void 0 ? void 0 : _e.channels) !== undefined; - var hasGroupPatterns = ((_f = incomingParams === null || incomingParams === void 0 ? void 0 : incomingParams.patterns) === null || _f === void 0 ? void 0 : _f.groups) !== undefined; - var hasLegacyTerms = hasAuthorizedUuid || - hasUuidResources || - hasUuidPatterns || - hasChannelResources || - hasChannelPatterns || - hasGroupResources || - hasGroupPatterns; - if (hasVspTerms(incomingParams) && hasLegacyTerms) { - return ('Cannot mix `users`, `spaces` and `authorizedUserId` ' + - 'with `uuids`, `channels`, `groups` and `authorized_uuid`'); - } - if ((incomingParams.resources && - (!incomingParams.resources.uuids || Object.keys(incomingParams.resources.uuids).length === 0) && - (!incomingParams.resources.channels || Object.keys(incomingParams.resources.channels).length === 0) && - (!incomingParams.resources.groups || Object.keys(incomingParams.resources.groups).length === 0) && - (!incomingParams.resources.users || Object.keys(incomingParams.resources.users).length === 0) && - (!incomingParams.resources.spaces || Object.keys(incomingParams.resources.spaces).length === 0)) || - (incomingParams.patterns && - (!incomingParams.patterns.uuids || Object.keys(incomingParams.patterns.uuids).length === 0) && - (!incomingParams.patterns.channels || Object.keys(incomingParams.patterns.channels).length === 0) && - (!incomingParams.patterns.groups || Object.keys(incomingParams.patterns.groups).length === 0) && - (!incomingParams.patterns.users || Object.keys(incomingParams.patterns.users).length === 0) && - (!incomingParams.patterns.spaces || Object.keys(incomingParams.patterns.spaces).length === 0))) { - return 'Missing values for either Resources or Patterns.'; - } - } - function postURL$1(modules) { - var config = modules.config; - return "/v3/pam/".concat(config.subscribeKey, "/grant"); - } - function usePost$1() { - return true; - } - function getRequestTimeout$8(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$8() { - return false; - } - function prepareParams$8() { - return {}; - } - function postPayload$1(modules, incomingParams) { - return prepareMessagePayload$2(modules, incomingParams); - } - function handleResponse$8(modules, response) { - var token = response.data.token; - return token; - } - - var grantTokenEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$8, - extractPermissions: extractPermissions, - validateParams: validateParams$8, - postURL: postURL$1, - usePost: usePost$1, - getRequestTimeout: getRequestTimeout$8, - isAuthSupported: isAuthSupported$8, - prepareParams: prepareParams$8, - postPayload: postPayload$1, - handleResponse: handleResponse$8 - }); - - /** */ - var endpoint$2 = { - getOperation: function () { return OPERATIONS.PNAccessManagerRevokeToken; }, - validateParams: function (modules, token) { - var secretKey = modules.config.secretKey; - if (!secretKey) { - return 'Missing Secret Key'; - } - if (!token) { - return "token can't be empty"; - } - }, - getURL: function (_a, token) { - var config = _a.config; - return "/v3/pam/".concat(config.subscribeKey, "/grant/").concat(utils$5.encodeString(token)); - }, - useDelete: function () { return true; }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getTransactionTimeout(); - }, - isAuthSupported: function () { return false; }, - prepareParams: function (_a) { - var config = _a.config; - return ({ - uuid: config.getUUID(), - }); - }, - handleResponse: function (_, response) { return ({ - status: response.status, - data: response.data, - }); }, - }; - - /* */ - function prepareMessagePayload$1(modules, messagePayload) { - var crypto = modules.crypto, config = modules.config; - var stringifiedPayload = JSON.stringify(messagePayload); - if (config.cipherKey) { - stringifiedPayload = crypto.encrypt(stringifiedPayload); - stringifiedPayload = JSON.stringify(stringifiedPayload); - } - return stringifiedPayload; - } - function getOperation$7() { - return OPERATIONS.PNPublishOperation; - } - function validateParams$7(_a, incomingParams) { - var config = _a.config; - var message = incomingParams.message, channel = incomingParams.channel; - if (!channel) - return 'Missing Channel'; - if (!message) - return 'Missing Message'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function usePost(modules, incomingParams) { - var _a = incomingParams.sendByPost, sendByPost = _a === void 0 ? false : _a; - return sendByPost; - } - function getURL$7(modules, incomingParams) { - var config = modules.config; - var channel = incomingParams.channel, message = incomingParams.message; - var stringifiedPayload = prepareMessagePayload$1(modules, message); - return "/publish/".concat(config.publishKey, "/").concat(config.subscribeKey, "/0/").concat(utils$5.encodeString(channel), "/0/").concat(utils$5.encodeString(stringifiedPayload)); - } - function postURL(modules, incomingParams) { - var config = modules.config; - var channel = incomingParams.channel; - return "/publish/".concat(config.publishKey, "/").concat(config.subscribeKey, "/0/").concat(utils$5.encodeString(channel), "/0"); - } - function getRequestTimeout$7(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$7() { - return true; - } - function postPayload(modules, incomingParams) { - var message = incomingParams.message; - return prepareMessagePayload$1(modules, message); - } - function prepareParams$7(modules, incomingParams) { - var meta = incomingParams.meta, _a = incomingParams.replicate, replicate = _a === void 0 ? true : _a, storeInHistory = incomingParams.storeInHistory, ttl = incomingParams.ttl; - var params = {}; - if (storeInHistory != null) { - if (storeInHistory) { - params.store = '1'; - } - else { - params.store = '0'; - } - } - if (ttl) { - params.ttl = ttl; - } - if (replicate === false) { - params.norep = 'true'; - } - if (meta && typeof meta === 'object') { - params.meta = JSON.stringify(meta); - } - return params; - } - function handleResponse$7(modules, serverResponse) { - return { timetoken: serverResponse[2] }; - } - - var publishEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$7, - validateParams: validateParams$7, - usePost: usePost, - getURL: getURL$7, - postURL: postURL, - getRequestTimeout: getRequestTimeout$7, - isAuthSupported: isAuthSupported$7, - postPayload: postPayload, - prepareParams: prepareParams$7, - handleResponse: handleResponse$7 - }); - - /* */ - function prepareMessagePayload(modules, messagePayload) { - var stringifiedPayload = JSON.stringify(messagePayload); - return stringifiedPayload; - } - function getOperation$6() { - return OPERATIONS.PNSignalOperation; - } - function validateParams$6(_a, incomingParams) { - var config = _a.config; - var message = incomingParams.message, channel = incomingParams.channel; - if (!channel) - return 'Missing Channel'; - if (!message) - return 'Missing Message'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$6(modules, incomingParams) { - var config = modules.config; - var channel = incomingParams.channel, message = incomingParams.message; - var stringifiedPayload = prepareMessagePayload(modules, message); - return "/signal/".concat(config.publishKey, "/").concat(config.subscribeKey, "/0/").concat(utils$5.encodeString(channel), "/0/").concat(utils$5.encodeString(stringifiedPayload)); - } - function getRequestTimeout$6(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$6() { - return true; - } - function prepareParams$6() { - var params = {}; - return params; - } - function handleResponse$6(modules, serverResponse) { - return { timetoken: serverResponse[2] }; - } - - var signalEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$6, - validateParams: validateParams$6, - getURL: getURL$6, - getRequestTimeout: getRequestTimeout$6, - isAuthSupported: isAuthSupported$6, - prepareParams: prepareParams$6, - handleResponse: handleResponse$6 - }); - - /* */ - function __processMessage$1(modules, message) { - var config = modules.config, crypto = modules.crypto; - if (!config.cipherKey) - return message; - try { - return crypto.decrypt(message); - } - catch (e) { - return message; - } - } - function getOperation$5() { - return OPERATIONS.PNHistoryOperation; - } - function validateParams$5(modules, incomingParams) { - var channel = incomingParams.channel; - var config = modules.config; - if (!channel) - return 'Missing channel'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$5(modules, incomingParams) { - var channel = incomingParams.channel; - var config = modules.config; - return "/v2/history/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel)); - } - function getRequestTimeout$5(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$5() { - return true; - } - function prepareParams$5(modules, incomingParams) { - var start = incomingParams.start, end = incomingParams.end, reverse = incomingParams.reverse, _a = incomingParams.count, count = _a === void 0 ? 100 : _a, _b = incomingParams.stringifiedTimeToken, stringifiedTimeToken = _b === void 0 ? false : _b, _c = incomingParams.includeMeta, includeMeta = _c === void 0 ? false : _c; - var outgoingParams = { - include_token: 'true', - }; - outgoingParams.count = count; - if (start) - outgoingParams.start = start; - if (end) - outgoingParams.end = end; - if (stringifiedTimeToken) - outgoingParams.string_message_token = 'true'; - if (reverse != null) - outgoingParams.reverse = reverse.toString(); - if (includeMeta) - outgoingParams.include_meta = 'true'; - return outgoingParams; - } - function handleResponse$5(modules, serverResponse) { - var response = { - messages: [], - startTimeToken: serverResponse[1], - endTimeToken: serverResponse[2], - }; - if (Array.isArray(serverResponse[0])) { - serverResponse[0].forEach(function (serverHistoryItem) { - var item = { - timetoken: serverHistoryItem.timetoken, - entry: __processMessage$1(modules, serverHistoryItem.message), - }; - if (serverHistoryItem.meta) { - item.meta = serverHistoryItem.meta; - } - response.messages.push(item); - }); - } - return response; - } - - var historyEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$5, - validateParams: validateParams$5, - getURL: getURL$5, - getRequestTimeout: getRequestTimeout$5, - isAuthSupported: isAuthSupported$5, - prepareParams: prepareParams$5, - handleResponse: handleResponse$5 - }); - - /* */ - function getOperation$4() { - return OPERATIONS.PNDeleteMessagesOperation; - } - function validateParams$4(modules, incomingParams) { - var channel = incomingParams.channel; - var config = modules.config; - if (!channel) - return 'Missing channel'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function useDelete() { - return true; - } - function getURL$4(modules, incomingParams) { - var channel = incomingParams.channel; - var config = modules.config; - return "/v3/history/sub-key/".concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(channel)); - } - function getRequestTimeout$4(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$4() { - return true; - } - function prepareParams$4(modules, incomingParams) { - var start = incomingParams.start, end = incomingParams.end; - var outgoingParams = {}; - if (start) - outgoingParams.start = start; - if (end) - outgoingParams.end = end; - return outgoingParams; - } - function handleResponse$4(modules, serverResponse) { - return serverResponse.payload; - } - - var deleteMessagesEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$4, - validateParams: validateParams$4, - useDelete: useDelete, - getURL: getURL$4, - getRequestTimeout: getRequestTimeout$4, - isAuthSupported: isAuthSupported$4, - prepareParams: prepareParams$4, - handleResponse: handleResponse$4 - }); - - /* */ - function getOperation$3() { - return OPERATIONS.PNMessageCounts; - } - function validateParams$3(modules, incomingParams) { - var channels = incomingParams.channels, timetoken = incomingParams.timetoken, channelTimetokens = incomingParams.channelTimetokens; - var config = modules.config; - if (!channels) - return 'Missing channel'; - if (timetoken && channelTimetokens) - return 'timetoken and channelTimetokens are incompatible together'; - if (timetoken && channelTimetokens && channelTimetokens.length > 1 && channels.length !== channelTimetokens.length) { - return 'Length of channelTimetokens and channels do not match'; - } - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL$3(modules, incomingParams) { - var channels = incomingParams.channels; - var config = modules.config; - var stringifiedChannels = channels.join(','); - return "/v3/history/sub-key/".concat(config.subscribeKey, "/message-counts/").concat(utils$5.encodeString(stringifiedChannels)); - } - function getRequestTimeout$3(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$3() { - return true; - } - function prepareParams$3(modules, incomingParams) { - var timetoken = incomingParams.timetoken, channelTimetokens = incomingParams.channelTimetokens; - var outgoingParams = {}; - if (channelTimetokens && channelTimetokens.length === 1) { - var _a = __read(channelTimetokens, 1), tt = _a[0]; - outgoingParams.timetoken = tt; - } - else if (channelTimetokens) { - outgoingParams.channelsTimetoken = channelTimetokens.join(','); - } - else if (timetoken) { - outgoingParams.timetoken = timetoken; - } - return outgoingParams; - } - function handleResponse$3(modules, serverResponse) { - return { channels: serverResponse.channels }; - } - - var messageCountsEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$3, - validateParams: validateParams$3, - getURL: getURL$3, - getRequestTimeout: getRequestTimeout$3, - isAuthSupported: isAuthSupported$3, - prepareParams: prepareParams$3, - handleResponse: handleResponse$3 - }); - - /* */ - function __processMessage(modules, message) { - var config = modules.config, crypto = modules.crypto; - if (!config.cipherKey) - return message; - try { - return crypto.decrypt(message); - } - catch (e) { - return message; - } - } - function getOperation$2() { - return OPERATIONS.PNFetchMessagesOperation; - } - function validateParams$2(modules, incomingParams) { - var channels = incomingParams.channels, _a = incomingParams.includeMessageActions, includeMessageActions = _a === void 0 ? false : _a; - var config = modules.config; - if (!channels || channels.length === 0) - return 'Missing channels'; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - if (includeMessageActions && channels.length > 1) { - throw new TypeError('History can return actions data for a single channel only. ' + - 'Either pass a single channel or disable the includeMessageActions flag.'); - } - } - function getURL$2(modules, incomingParams) { - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a, _b = incomingParams.includeMessageActions, includeMessageActions = _b === void 0 ? false : _b; - var config = modules.config; - var endpoint = !includeMessageActions ? 'history' : 'history-with-actions'; - var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; - return "/v3/".concat(endpoint, "/sub-key/").concat(config.subscribeKey, "/channel/").concat(utils$5.encodeString(stringifiedChannels)); - } - function getRequestTimeout$2(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function isAuthSupported$2() { - return true; - } - function prepareParams$2(modules, incomingParams) { - var channels = incomingParams.channels, start = incomingParams.start, end = incomingParams.end, includeMessageActions = incomingParams.includeMessageActions, count = incomingParams.count, _a = incomingParams.stringifiedTimeToken, stringifiedTimeToken = _a === void 0 ? false : _a, _b = incomingParams.includeMeta, includeMeta = _b === void 0 ? false : _b, includeUuid = incomingParams.includeUuid, _c = incomingParams.includeUUID, includeUUID = _c === void 0 ? true : _c, _d = incomingParams.includeMessageType, includeMessageType = _d === void 0 ? true : _d; - var outgoingParams = {}; - if (count) { - outgoingParams.max = count; - } - else { - outgoingParams.max = channels.length > 1 || includeMessageActions === true ? 25 : 100; - } - if (start) - outgoingParams.start = start; - if (end) - outgoingParams.end = end; - if (stringifiedTimeToken) - outgoingParams.string_message_token = 'true'; - if (includeMeta) - outgoingParams.include_meta = 'true'; - if (includeUUID && includeUuid !== false) - outgoingParams.include_uuid = 'true'; - if (includeMessageType) - outgoingParams.include_message_type = 'true'; - return outgoingParams; - } - function handleResponse$2(modules, serverResponse) { - var response = { - channels: {}, - }; - Object.keys(serverResponse.channels || {}).forEach(function (channelName) { - response.channels[channelName] = []; - (serverResponse.channels[channelName] || []).forEach(function (messageEnvelope) { - var announce = {}; - announce.channel = channelName; - announce.timetoken = messageEnvelope.timetoken; - announce.message = __processMessage(modules, messageEnvelope.message); - announce.messageType = messageEnvelope.message_type; - announce.uuid = messageEnvelope.uuid; - if (messageEnvelope.actions) { - announce.actions = messageEnvelope.actions; - // This should be kept for few updates for existing clients consistency. - announce.data = messageEnvelope.actions; - } - if (messageEnvelope.meta) { - announce.meta = messageEnvelope.meta; - } - response.channels[channelName].push(announce); - }); - }); - if (serverResponse.more) { - response.more = serverResponse.more; - } - return response; - } - - var fetchMessagesEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$2, - validateParams: validateParams$2, - getURL: getURL$2, - getRequestTimeout: getRequestTimeout$2, - isAuthSupported: isAuthSupported$2, - prepareParams: prepareParams$2, - handleResponse: handleResponse$2 - }); - - /* */ - function getOperation$1() { - return OPERATIONS.PNTimeOperation; - } - function getURL$1() { - return '/time/0'; - } - function getRequestTimeout$1(_a) { - var config = _a.config; - return config.getTransactionTimeout(); - } - function prepareParams$1() { - return {}; - } - function isAuthSupported$1() { - return false; - } - function handleResponse$1(modules, serverResponse) { - return { - timetoken: serverResponse[0], - }; - } - function validateParams$1() { - // pass - } - - var timeEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation$1, - getURL: getURL$1, - getRequestTimeout: getRequestTimeout$1, - prepareParams: prepareParams$1, - isAuthSupported: isAuthSupported$1, - handleResponse: handleResponse$1, - validateParams: validateParams$1 - }); - - /* */ - function getOperation() { - return OPERATIONS.PNSubscribeOperation; - } - function validateParams(modules) { - var config = modules.config; - if (!config.subscribeKey) - return 'Missing Subscribe Key'; - } - function getURL(modules, incomingParams) { - var config = modules.config; - var _a = incomingParams.channels, channels = _a === void 0 ? [] : _a; - var stringifiedChannels = channels.length > 0 ? channels.join(',') : ','; - return "/v2/subscribe/".concat(config.subscribeKey, "/").concat(utils$5.encodeString(stringifiedChannels), "/0"); - } - function getRequestTimeout(_a) { - var config = _a.config; - return config.getSubscribeTimeout(); - } - function isAuthSupported() { - return true; - } - function prepareParams(_a, incomingParams) { - var config = _a.config; - var state = incomingParams.state, _b = incomingParams.channelGroups, channelGroups = _b === void 0 ? [] : _b, timetoken = incomingParams.timetoken, filterExpression = incomingParams.filterExpression, region = incomingParams.region; - var params = { - heartbeat: config.getPresenceTimeout(), - }; - if (channelGroups.length > 0) { - params['channel-group'] = channelGroups.join(','); - } - if (filterExpression && filterExpression.length > 0) { - params['filter-expr'] = filterExpression; - } - if (Object.keys(state).length) { - params.state = JSON.stringify(state); - } - if (timetoken) { - params.tt = timetoken; - } - if (region) { - params.tr = region; - } - return params; - } - function handleResponse(modules, serverResponse) { - var messages = []; - serverResponse.m.forEach(function (rawMessage) { - var publishMetaData = { - publishTimetoken: rawMessage.p.t, - region: rawMessage.p.r, - }; - var parsedMessage = { - shard: parseInt(rawMessage.a, 10), - subscriptionMatch: rawMessage.b, - channel: rawMessage.c, - messageType: rawMessage.e, - payload: rawMessage.d, - flags: rawMessage.f, - issuingClientId: rawMessage.i, - subscribeKey: rawMessage.k, - originationTimetoken: rawMessage.o, - userMetadata: rawMessage.u, - publishMetaData: publishMetaData, - }; - messages.push(parsedMessage); - }); - var metadata = { - timetoken: serverResponse.t.t, - region: serverResponse.t.r, - }; - return { messages: messages, metadata: metadata }; - } - - var subscribeEndpointConfig = /*#__PURE__*/Object.freeze({ - __proto__: null, - getOperation: getOperation, - validateParams: validateParams, - getURL: getURL, - getRequestTimeout: getRequestTimeout, - isAuthSupported: isAuthSupported, - prepareParams: prepareParams, - handleResponse: handleResponse - }); - - var endpoint$1 = { - getOperation: function () { return OPERATIONS.PNHandshakeOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channels) && !(params === null || params === void 0 ? void 0 : params.channelGroups)) { - return 'channels and channleGroups both should not be empty'; - } - }, - getURL: function (_a, params) { - var config = _a.config; - var channelsString = params.channels ? params.channels.join(',') : ','; - return "/v2/subscribe/".concat(config.subscribeKey, "/").concat(utils$5.encodeString(channelsString), "/0"); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getSubscribeTimeout(); - }, - isAuthSupported: function () { return true; }, - prepareParams: function (_, params) { - var outParams = {}; - if (params.channelGroups && params.channelGroups.length > 0) { - outParams['channel-group'] = params.channelGroups.join(','); - } - outParams.tt = 0; - return outParams; - }, - handleResponse: function (_, response) { return ({ - region: response.t.r, - timetoken: response.t.t, - }); }, - }; - - var endpoint = { - getOperation: function () { return OPERATIONS.PNReceiveMessagesOperation; }, - validateParams: function (_, params) { - if (!(params === null || params === void 0 ? void 0 : params.channels) && !(params === null || params === void 0 ? void 0 : params.channelGroups)) { - return 'channels and channleGroups both should not be empty'; - } - if (!(params === null || params === void 0 ? void 0 : params.timetoken)) { - return 'timetoken can not be empty'; - } - if (!(params === null || params === void 0 ? void 0 : params.region)) { - return 'region can not be empty'; - } - }, - getURL: function (_a, params) { - var config = _a.config; - var channelsString = params.channels ? params.channels.join(',') : ','; - return "/v2/subscribe/".concat(config.subscribeKey, "/").concat(utils$5.encodeString(channelsString), "/0"); - }, - getRequestTimeout: function (_a) { - var config = _a.config; - return config.getSubscribeTimeout(); - }, - isAuthSupported: function () { return true; }, - getAbortSignal: function (_, params) { return params.abortSignal; }, - prepareParams: function (_, params) { - var outParams = {}; - if (params.channelGroups && params.channelGroups.length > 0) { - outParams['channel-group'] = params.channelGroups.join(','); - } - outParams.tt = params.timetoken; - outParams.tr = params.region; - return outParams; - }, - handleResponse: function (_, response) { - var parsedMessages = []; - response.m.forEach(function (envelope) { - var parsedMessage = { - shard: parseInt(envelope.a, 10), - subscriptionMatch: envelope.b, - channel: envelope.c, - messageType: envelope.e, - payload: envelope.d, - flags: envelope.f, - issuingClientId: envelope.i, - subscribeKey: envelope.k, - originationTimetoken: envelope.o, - publishMetaData: { - timetoken: envelope.p.t, - region: envelope.p.r, - }, - }; - parsedMessages.push(parsedMessage); - }); - return { - messages: parsedMessages, - metadata: { - region: response.t.r, - timetoken: response.t.t, - }, - }; - }, - }; - - var Subject = /** @class */ (function () { - function Subject(sync) { - if (sync === void 0) { sync = false; } - this.sync = sync; - this.listeners = new Set(); - } - Subject.prototype.subscribe = function (listener) { - var _this = this; - this.listeners.add(listener); - return function () { - _this.listeners.delete(listener); - }; - }; - Subject.prototype.notify = function (event) { - var _this = this; - var wrapper = function () { - _this.listeners.forEach(function (listener) { - listener(event); - }); - }; - if (this.sync) { - wrapper(); - } - else { - setTimeout(wrapper, 0); - } - }; - return Subject; - }()); - - /* eslint-disable @typescript-eslint/no-explicit-any */ - var State = /** @class */ (function () { - function State(label) { - this.label = label; - this.transitionMap = new Map(); - this.enterEffects = []; - this.exitEffects = []; - } - State.prototype.transition = function (context, event) { - var _a; - if (this.transitionMap.has(event.type)) { - return (_a = this.transitionMap.get(event.type)) === null || _a === void 0 ? void 0 : _a(context, event); - } - return undefined; - }; - State.prototype.on = function (eventType, transition) { - this.transitionMap.set(eventType, transition); - return this; - }; - State.prototype.with = function (context, effects) { - return [this, context, effects !== null && effects !== void 0 ? effects : []]; - }; - State.prototype.onEnter = function (effect) { - this.enterEffects.push(effect); - return this; - }; - State.prototype.onExit = function (effect) { - this.exitEffects.push(effect); - return this; - }; - return State; - }()); - - /* eslint-disable @typescript-eslint/no-explicit-any */ - var Engine = /** @class */ (function (_super) { - __extends(Engine, _super); - function Engine() { - return _super !== null && _super.apply(this, arguments) || this; - } - Engine.prototype.describe = function (label) { - return new State(label); - }; - Engine.prototype.start = function (initialState, initialContext) { - this.currentState = initialState; - this.currentContext = initialContext; - this.notify({ - type: 'engineStarted', - state: initialState, - context: initialContext, - }); - return; - }; - Engine.prototype.transition = function (event) { - var e_1, _a, e_2, _b, e_3, _c; - if (!this.currentState) { - throw new Error('Start the engine first'); - } - this.notify({ - type: 'eventReceived', - event: event, - }); - var transition = this.currentState.transition(this.currentContext, event); - if (transition) { - var _d = __read(transition, 3), newState = _d[0], newContext = _d[1], effects = _d[2]; - try { - for (var _e = __values(this.currentState.exitEffects), _f = _e.next(); !_f.done; _f = _e.next()) { - var effect = _f.value; - this.notify({ - type: 'invocationDispatched', - invocation: effect(this.currentContext), - }); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_f && !_f.done && (_a = _e.return)) _a.call(_e); - } - finally { if (e_1) throw e_1.error; } - } - var oldState = this.currentState; - this.currentState = newState; - var oldContext = this.currentContext; - this.currentContext = newContext; - this.notify({ - type: 'transitionDone', - fromState: oldState, - fromContext: oldContext, - toState: newState, - toContext: newContext, - event: event, - }); - try { - for (var effects_1 = __values(effects), effects_1_1 = effects_1.next(); !effects_1_1.done; effects_1_1 = effects_1.next()) { - var effect = effects_1_1.value; - this.notify({ - type: 'invocationDispatched', - invocation: effect, - }); - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (effects_1_1 && !effects_1_1.done && (_b = effects_1.return)) _b.call(effects_1); - } - finally { if (e_2) throw e_2.error; } - } - try { - for (var _g = __values(this.currentState.enterEffects), _h = _g.next(); !_h.done; _h = _g.next()) { - var effect = _h.value; - this.notify({ - type: 'invocationDispatched', - invocation: effect(this.currentContext), - }); - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_h && !_h.done && (_c = _g.return)) _c.call(_g); - } - finally { if (e_3) throw e_3.error; } - } - } - }; - return Engine; - }(Subject)); - - /* eslint-disable @typescript-eslint/no-explicit-any */ - var Dispatcher = /** @class */ (function () { - function Dispatcher(dependencies) { - this.dependencies = dependencies; - this.instances = new Map(); - this.handlers = new Map(); - } - Dispatcher.prototype.on = function (type, handlerCreator) { - this.handlers.set(type, handlerCreator); - }; - Dispatcher.prototype.dispatch = function (invocation) { - if (invocation.type === 'CANCEL') { - if (this.instances.has(invocation.payload)) { - var instance_1 = this.instances.get(invocation.payload); - instance_1 === null || instance_1 === void 0 ? void 0 : instance_1.cancel(); - this.instances.delete(invocation.payload); - } - return; - } - var handlerCreator = this.handlers.get(invocation.type); - if (!handlerCreator) { - throw new Error("Unhandled invocation '".concat(invocation.type, "'")); - } - var instance = handlerCreator(invocation.payload, this.dependencies); - if (invocation.managed) { - this.instances.set(invocation.type, instance); - } - instance.start(); - }; - Dispatcher.prototype.dispose = function () { - var e_1, _a; - try { - for (var _b = __values(this.instances.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { - var _d = __read(_c.value, 2), key = _d[0], instance = _d[1]; - instance.cancel(); - this.instances.delete(key); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_1) throw e_1.error; } - } - }; - return Dispatcher; - }()); - - /* eslint-disable @typescript-eslint/no-explicit-any */ - function createEvent(type, fn) { - var creator = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return { - type: type, - payload: fn === null || fn === void 0 ? void 0 : fn.apply(void 0, __spreadArray([], __read(args), false)), - }; - }; - creator.type = type; - return creator; - } - function createEffect(type, fn) { - var creator = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return { type: type, payload: fn.apply(void 0, __spreadArray([], __read(args), false)), managed: false }; - }; - creator.type = type; - return creator; - } - function createManagedEffect(type, fn) { - var creator = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return { type: type, payload: fn.apply(void 0, __spreadArray([], __read(args), false)), managed: true }; - }; - creator.type = type; - creator.cancel = { type: 'CANCEL', payload: type, managed: false }; - return creator; - } - - var AbortError = /** @class */ (function (_super) { - __extends(AbortError, _super); - function AbortError() { - var _newTarget = this.constructor; - var _this = _super.call(this, 'The operation was aborted.') || this; - _this.name = 'AbortError'; - Object.setPrototypeOf(_this, _newTarget.prototype); - return _this; - } - return AbortError; - }(Error)); - var AbortSignal = /** @class */ (function (_super) { - __extends(AbortSignal, _super); - function AbortSignal() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._aborted = false; - return _this; - } - Object.defineProperty(AbortSignal.prototype, "aborted", { - get: function () { - return this._aborted; - }, - enumerable: false, - configurable: true - }); - AbortSignal.prototype.throwIfAborted = function () { - if (this._aborted) { - throw new AbortError(); - } - }; - AbortSignal.prototype.abort = function () { - this._aborted = true; - this.notify(new AbortError()); - }; - return AbortSignal; - }(Subject)); - - var Handler = /** @class */ (function () { - function Handler(payload, dependencies) { - this.payload = payload; - this.dependencies = dependencies; - } - return Handler; - }()); - var AsyncHandler = /** @class */ (function (_super) { - __extends(AsyncHandler, _super); - function AsyncHandler(payload, dependencies, asyncFunction) { - var _this = _super.call(this, payload, dependencies) || this; - _this.asyncFunction = asyncFunction; - _this.abortSignal = new AbortSignal(); - return _this; - } - AsyncHandler.prototype.start = function () { - this.asyncFunction(this.payload, this.abortSignal, this.dependencies).catch(function (error) { - // console.log('Unhandled error:', error); - // swallow the error - }); - }; - AsyncHandler.prototype.cancel = function () { - this.abortSignal.abort(); - }; - return AsyncHandler; - }(Handler)); - var asyncHandler = function (handlerFunction) { - return function (payload, dependencies) { - return new AsyncHandler(payload, dependencies, handlerFunction); - }; - }; - - var handshake = createManagedEffect('HANDSHAKE', function (channels, groups) { return ({ - channels: channels, - groups: groups, - }); }); - var receiveEvents = createManagedEffect('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); - var emitEvents = createEffect('EMIT_MESSAGES', function (events) { return events; }); - var emitStatus = createEffect('EMIT_STATUS', function (status) { return status; }); - var reconnect$1 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); - var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); - - var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ - channels: channels, - groups: groups, - timetoken: timetoken - }); }); - var disconnect = createEvent('DISCONNECT', function () { return ({}); }); - var reconnect = createEvent('RECONNECT', function () { return ({}); }); - var restore = createEvent('RESTORE', function (channels, groups, timetoken, region) { return ({ - channels: channels, - groups: groups, - timetoken: timetoken, - region: region, - }); }); - var handshakingSuccess = createEvent('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); - var handshakingFailure = createEvent('HANDSHAKE_FAILURE', function (error) { return error; }); - var handshakingReconnectingSuccess = createEvent('HANDSHAKING_RECONNECTING_SUCCESS', function (cursor) { return ({ - cursor: cursor, - }); }); - var handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); - var handshakingReconnectingGiveup = createEvent('HANDSHAKING_RECONNECTING_GIVEUP', function () { return ({}); }); - var handshakingReconnectingRetry = createEvent('HANDSHAKING_RECONNECTING_RETRY', function () { return ({}); }); - var receivingSuccess = createEvent('RECEIVE_SUCCESS', function (cursor, events) { return ({ - cursor: cursor, - events: events, - }); }); - var receivingFailure = createEvent('RECEIVE_FAILURE', function (error) { return error; }); - var reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ - cursor: cursor, - events: events, - }); }); - var reconnectingFailure = createEvent('RECEIVING_RECONNECTING_FAILURE', function (error) { return error; }); - var reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); - var reconnectingRetry = createEvent('RECEIVING_RECONNECTING_RETRY', function () { return ({}); }); - - var EventEngineDispatcher = /** @class */ (function (_super) { - __extends(EventEngineDispatcher, _super); - function EventEngineDispatcher(engine, dependencies) { - var _this = _super.call(this, dependencies) || this; - _this.on(handshake.type, asyncHandler(function (payload, abortSignal, _a) { - var handshake = _a.handshake; - return __awaiter(_this, void 0, void 0, function () { - var result, e_1; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - abortSignal.throwIfAborted(); - _b.label = 1; - case 1: - _b.trys.push([1, 3, , 4]); - return [4 /*yield*/, handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - })]; - case 2: - result = _b.sent(); - engine.transition(handshakingSuccess(result)); - return [3 /*break*/, 4]; - case 3: - e_1 = _b.sent(); - if (e_1 instanceof Error && e_1.message === 'Aborted') { - return [2 /*return*/]; - } - if (e_1 instanceof PubNubError) { - return [2 /*return*/, engine.transition(handshakingFailure(e_1))]; - } - return [3 /*break*/, 4]; - case 4: return [2 /*return*/]; - } - }); - }); - })); - _this.on(receiveEvents.type, asyncHandler(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents; - return __awaiter(_this, void 0, void 0, function () { - var result, error_1; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - abortSignal.throwIfAborted(); - _b.label = 1; - case 1: - _b.trys.push([1, 3, , 4]); - return [4 /*yield*/, receiveEvents({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - timetoken: payload.cursor.timetoken, - region: payload.cursor.region, - })]; - case 2: - result = _b.sent(); - engine.transition(receivingSuccess(result.metadata, result.messages)); - return [3 /*break*/, 4]; - case 3: - error_1 = _b.sent(); - if (error_1 instanceof Error && error_1.message === 'Aborted') { - return [2 /*return*/]; - } - if (error_1 instanceof PubNubError && !abortSignal.aborted) { - return [2 /*return*/, engine.transition(receivingFailure(error_1))]; - } - return [3 /*break*/, 4]; - case 4: return [2 /*return*/]; - } - }); - }); - })); - _this.on(emitEvents.type, asyncHandler(function (payload, abortSignal, _a) { - var emitEvents = _a.emitEvents; - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_b) { - if (payload.length > 0) { - emitEvents(payload); - } - return [2 /*return*/]; - }); - }); - })); - _this.on(emitStatus.type, asyncHandler(function (payload, abortSignal, _a) { - var emitStatus = _a.emitStatus; - return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_b) { - emitStatus(payload); - return [2 /*return*/]; - }); - }); - })); - _this.on(reconnect$1.type, asyncHandler(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; - return __awaiter(_this, void 0, void 0, function () { - var result, error_2; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!shouldRetry(payload.reason, payload.attempts)) { - return [2 /*return*/, engine.transition(reconnectingGiveup())]; - } - abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; - case 1: - _b.sent(); - abortSignal.throwIfAborted(); - _b.label = 2; - case 2: - _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, receiveEvents({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - timetoken: payload.cursor.timetoken, - region: payload.cursor.region, - })]; - case 3: - result = _b.sent(); - return [2 /*return*/, engine.transition(reconnectingSuccess(result.metadata, result.messages))]; - case 4: - error_2 = _b.sent(); - if (error_2 instanceof Error && error_2.message === 'Aborted') { - return [2 /*return*/]; - } - if (error_2 instanceof PubNubError) { - return [2 /*return*/, engine.transition(reconnectingFailure(error_2))]; - } - return [3 /*break*/, 5]; - case 5: return [2 /*return*/]; - } - }); - }); - })); - _this.on(handshakeReconnect.type, asyncHandler(function (payload, abortSignal, _a) { - var handshake = _a.handshake, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; - return __awaiter(_this, void 0, void 0, function () { - var result, error_3; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!shouldRetry(payload.reason, payload.attempts)) { - return [2 /*return*/, engine.transition(handshakingReconnectingGiveup())]; - } - abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; - case 1: - _b.sent(); - abortSignal.throwIfAborted(); - _b.label = 2; - case 2: - _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - })]; - case 3: - result = _b.sent(); - return [2 /*return*/, engine.transition(handshakingReconnectingSuccess(result))]; - case 4: - error_3 = _b.sent(); - if (error_3 instanceof Error && error_3.message === 'Aborted') { - return [2 /*return*/]; - } - if (error_3 instanceof PubNubError) { - return [2 /*return*/, engine.transition(handshakingReconnectingFailure(error_3))]; - } - return [3 /*break*/, 5]; - case 5: return [2 /*return*/]; - } - }); - }); - })); - return _this; - } - return EventEngineDispatcher; - }(Dispatcher)); - - var HandshakeStoppedState = new State('STOPPED'); - HandshakeStoppedState.on(subscriptionChange.type, function (_, event) { - return HandshakingState.with({ - channels: event.payload.channels, - groups: event.payload.groups, - }); - }); - HandshakeStoppedState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); - - var HandshakeFailureState = new State('HANDSHAKE_FAILURE'); - HandshakeFailureState.onEnter(function (context) { return emitStatus({ category: 'PNNetworkIssuesCategory' }); }); - HandshakeFailureState.on(handshakingReconnectingRetry.type, function (context) { - return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); - }); - HandshakeFailureState.on(disconnect.type, function (context) { - return HandshakeStoppedState.with({ - channels: context.channels, - groups: context.groups, - }); - }); - HandshakeFailureState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); - - var ReceiveStoppedState = new State('STOPPED'); - ReceiveStoppedState.on(subscriptionChange.type, function (context, event) { - return ReceivingState.with({ - channels: event.payload.channels, - groups: event.payload.groups, - cursor: context.cursor, - }); - }); - ReceiveStoppedState.on(reconnect.type, function (context) { return ReceivingState.with(__assign({}, context)); }); - - var ReceiveFailureState = new State('RECEIVE_FAILURE'); - ReceiveFailureState.on(reconnectingRetry.type, function (context) { - return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); - }); - ReceiveFailureState.on(disconnect.type, function (context) { - return ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }); - }); - - var ReceiveReconnectingState = new State('RECEIVE_RECONNECTING'); - ReceiveReconnectingState.onEnter(function (context) { return reconnect$1(context); }); - ReceiveReconnectingState.onExit(function () { return reconnect$1.cancel; }); - ReceiveReconnectingState.on(reconnectingSuccess.type, function (context, event) { - return ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: event.payload.cursor, - }, [emitEvents(event.payload.events)]); - }); - ReceiveReconnectingState.on(reconnectingFailure.type, function (context, event) { - return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); - }); - ReceiveReconnectingState.on(reconnectingGiveup.type, function (context) { - return ReceiveFailureState.with({ - groups: context.groups, - channels: context.channels, - cursor: context.cursor, - reason: context.reason, - }, [emitStatus({ category: 'PNDisconnectedCategory' })]); - }); - ReceiveReconnectingState.on(disconnect.type, function (context) { - return ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }, [emitStatus({ category: 'PNDisconnectedCategory' })]); - }); - ReceiveReconnectingState.on(restore.type, function (context) { - return ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }); - }); - ReceiveReconnectingState.on(subscriptionChange.type, function (context, event) { - return ReceivingState.with({ - channels: event.payload.channels, - groups: event.payload.groups, - cursor: context.cursor, - }); - }); - - var ReceivingState = new State('RECEIVING'); - ReceivingState.onEnter(function (_) { return emitStatus({ category: 'PNConnectedCategory' }); }); - ReceivingState.onEnter(function (context) { return receiveEvents(context.channels, context.groups, context.cursor); }); - ReceivingState.onExit(function () { return receiveEvents.cancel; }); - ReceivingState.on(receivingSuccess.type, function (context, event) { - return ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [emitEvents(event.payload.events)]); - }); - ReceivingState.on(subscriptionChange.type, function (context, event) { - if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { - return UnsubscribedState.with(undefined); - } - return ReceivingState.with(__assign(__assign({}, context), { channels: event.payload.channels, groups: event.payload.groups })); - }); - ReceivingState.on(receivingFailure.type, function (context, event) { - return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); - }); - ReceivingState.on(disconnect.type, function (context) { - return ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }, [emitStatus({ category: 'PNDisconnectedCategory' })]); - }); - - var HandshakeReconnectingState = new State('HANDSHAKE_RECONNECTING'); - HandshakeReconnectingState.onEnter(function (context) { return handshakeReconnect(context); }); - HandshakeReconnectingState.onExit(function () { return handshakeReconnect.cancel; }); - HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, function (context, event) { - return ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: event.payload.cursor, - }); - }); - HandshakeReconnectingState.on(handshakingReconnectingFailure.type, function (context, event) { - return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); - }); - HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, function (context) { - return HandshakeFailureState.with({ - groups: context.groups, - channels: context.channels, - reason: context.reason, - }); - }); - HandshakeReconnectingState.on(disconnect.type, function (context) { - return HandshakeStoppedState.with({ - channels: context.channels, - groups: context.groups, - }); - }); - HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); - }); - - var HandshakingState = new State('HANDSHAKING'); - HandshakingState.onEnter(function (context) { return handshake(context.channels, context.groups); }); - HandshakingState.onExit(function () { return handshake.cancel; }); - HandshakingState.on(subscriptionChange.type, function (context, event) { - if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { - return UnsubscribedState.with(undefined); - } - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); - }); - HandshakingState.on(handshakingSuccess.type, function (context, event) { - return ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: { - timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, - region: event.payload.region, - }, - }); - }); - HandshakingState.on(handshakingFailure.type, function (context, event) { - return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); - }); - HandshakingState.on(disconnect.type, function (context) { - return HandshakeStoppedState.with({ - channels: context.channels, - groups: context.groups, - }); - }); - - var UnsubscribedState = new State('UNSUBSCRIBED'); - UnsubscribedState.on(subscriptionChange.type, function (_, event) { - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, timetoken: event.payload.timetoken }); - }); - - var EventEngine = /** @class */ (function () { - function EventEngine(dependencies) { - var _this = this; - this.engine = new Engine(); - this.channels = []; - this.groups = []; - this.dispatcher = new EventEngineDispatcher(this.engine, dependencies); - this._unsubscribeEngine = this.engine.subscribe(function (change) { - if (change.type === 'invocationDispatched') { - _this.dispatcher.dispatch(change.invocation); - } - }); - this.engine.start(UnsubscribedState, undefined); - } - Object.defineProperty(EventEngine.prototype, "_engine", { - get: function () { - return this.engine; - }, - enumerable: false, - configurable: true - }); - EventEngine.prototype.subscribe = function (_a) { - var channels = _a.channels, groups = _a.groups, timetoken = _a.timetoken; - this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); - this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); - this.engine.transition(subscriptionChange(this.channels, this.groups, timetoken !== null && timetoken !== void 0 ? timetoken : '0')); - }; - EventEngine.prototype.unsubscribe = function (_a) { - var channels = _a.channels, groups = _a.groups; - this.channels = this.channels.filter(function (channel) { var _a; return (_a = !(channels === null || channels === void 0 ? void 0 : channels.includes(channel))) !== null && _a !== void 0 ? _a : true; }); - this.groups = this.groups.filter(function (group) { var _a; return (_a = !(groups === null || groups === void 0 ? void 0 : groups.includes(group))) !== null && _a !== void 0 ? _a : true; }); - this.engine.transition(subscriptionChange(this.channels.slice(0), this.groups.slice(0))); - }; - EventEngine.prototype.unsubscribeAll = function () { - this.channels = []; - this.groups = []; - this.engine.transition(subscriptionChange(this.channels.slice(0), this.groups.slice(0))); - }; - EventEngine.prototype.reconnect = function () { - this.engine.transition(reconnect()); - }; - EventEngine.prototype.disconnect = function () { - this.engine.transition(disconnect()); - }; - EventEngine.prototype.dispose = function () { - this.disconnect(); - this._unsubscribeEngine(); - this.dispatcher.dispose(); - }; - return EventEngine; - }()); - - var ReconnectionDelay = /** @class */ (function () { - function ReconnectionDelay() { - } - ReconnectionDelay.getDelay = function (policy, attempts, backoff) { - var backoffValue = backoff !== null && backoff !== void 0 ? backoff : 5; - switch (policy.toUpperCase()) { - case 'LINEAR': - return attempts * backoffValue + Math.random() * 1000; - case 'EXPONENTIAL': - return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; - default: - throw new Error('invalid policy'); - } - }; - return ReconnectionDelay; - }()); - - var default_1$3 = /** @class */ (function () { - // - function default_1(setup) { - var _this = this; - var _a; - var networking = setup.networking, cbor = setup.cbor; - var config = new default_1$b({ setup: setup }); - this._config = config; - var crypto = new default_1$a({ config: config }); // LEGACY - var cryptography = setup.cryptography; - networking.init(config); - var tokenManager = new default_1$4(config, cbor); - this._tokenManager = tokenManager; - var telemetryManager = new default_1$6({ - maximumSamplesCount: 60000, - }); - this._telemetryManager = telemetryManager; - var modules = { - config: config, - networking: networking, - crypto: crypto, - cryptography: cryptography, - tokenManager: tokenManager, - telemetryManager: telemetryManager, - PubNubFile: setup.PubNubFile, - }; - this.File = setup.PubNubFile; - this.encryptFile = function (key, file) { return cryptography.encryptFile(key, file, _this.File); }; - this.decryptFile = function (key, file) { return cryptography.decryptFile(key, file, _this.File); }; - var timeEndpoint = endpointCreator.bind(this, modules, timeEndpointConfig); - var leaveEndpoint = endpointCreator.bind(this, modules, presenceLeaveEndpointConfig); - var heartbeatEndpoint = endpointCreator.bind(this, modules, presenceHeartbeatEndpointConfig); - var setStateEndpoint = endpointCreator.bind(this, modules, presenceSetStateConfig); - var subscribeEndpoint = endpointCreator.bind(this, modules, subscribeEndpointConfig); - // managers - var listenerManager = new default_1$5(); - this._listenerManager = listenerManager; - this.iAmHere = endpointCreator.bind(this, modules, presenceHeartbeatEndpointConfig); - this.iAmAway = endpointCreator.bind(this, modules, presenceLeaveEndpointConfig); - this.setPresenceState = endpointCreator.bind(this, modules, presenceSetStateConfig); - this.handshake = endpointCreator.bind(this, modules, endpoint$1); - this.receiveMessages = endpointCreator.bind(this, modules, endpoint); - if (config.enableSubscribeBeta === true) { - var policy_1 = modules.config.reconnectionConfiguration.reconnectionPolicy; - var maxRetries_1 = (_a = modules.config.reconnectionConfiguration.maximumReconnectionRetries) !== null && _a !== void 0 ? _a : 0; - var eventEngine = new EventEngine({ - handshake: this.handshake, - receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return ReconnectionDelay.getDelay(policy_1, maxRetries_1); }, - delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (_, attempts) { return maxRetries_1 >= attempts && policy_1 && policy_1 != 'None'; }, - emitEvents: function (events) { - var e_1, _a; - try { - for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { - var event_1 = events_1_1.value; - listenerManager.announceMessage(event_1); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1); - } - finally { if (e_1) throw e_1.error; } - } - }, - emitStatus: function (status) { - listenerManager.announceStatus(status); - }, - }); - this.subscribe = eventEngine.subscribe.bind(eventEngine); - this.unsubscribe = eventEngine.unsubscribe.bind(eventEngine); - this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); - this.reconnect = eventEngine.reconnect.bind(eventEngine); - this.disconnect = eventEngine.disconnect.bind(eventEngine); - this.eventEngine = eventEngine; - } - else { - var subscriptionManager_1 = new default_1$7({ - timeEndpoint: timeEndpoint, - leaveEndpoint: leaveEndpoint, - heartbeatEndpoint: heartbeatEndpoint, - setStateEndpoint: setStateEndpoint, - subscribeEndpoint: subscribeEndpoint, - crypto: modules.crypto, - config: modules.config, - listenerManager: listenerManager, - getFileUrl: function (params) { return getFileUrlFunction(modules, params); }, - }); - this.subscribe = subscriptionManager_1.adaptSubscribeChange.bind(subscriptionManager_1); - this.unsubscribe = subscriptionManager_1.adaptUnsubscribeChange.bind(subscriptionManager_1); - this.disconnect = subscriptionManager_1.disconnect.bind(subscriptionManager_1); - this.reconnect = subscriptionManager_1.reconnect.bind(subscriptionManager_1); - this.unsubscribeAll = subscriptionManager_1.unsubscribeAll.bind(subscriptionManager_1); - this.getSubscribedChannels = subscriptionManager_1.getSubscribedChannels.bind(subscriptionManager_1); - this.getSubscribedChannelGroups = subscriptionManager_1.getSubscribedChannelGroups.bind(subscriptionManager_1); - this.setState = subscriptionManager_1.adaptStateChange.bind(subscriptionManager_1); - this.presence = subscriptionManager_1.adaptPresenceChange.bind(subscriptionManager_1); - this.destroy = function (isOffline) { - subscriptionManager_1.unsubscribeAll(isOffline); - subscriptionManager_1.disconnect(); - }; - } - this.addListener = listenerManager.addListener.bind(listenerManager); - this.removeListener = listenerManager.removeListener.bind(listenerManager); - this.removeAllListeners = listenerManager.removeAllListeners.bind(listenerManager); - this.parseToken = tokenManager.parseToken.bind(tokenManager); - this.setToken = tokenManager.setToken.bind(tokenManager); - this.getToken = tokenManager.getToken.bind(tokenManager); - /* channel groups */ - this.channelGroups = { - listGroups: endpointCreator.bind(this, modules, listChannelGroupsConfig), - listChannels: endpointCreator.bind(this, modules, listChannelsInChannelGroupConfig), - addChannels: endpointCreator.bind(this, modules, addChannelsChannelGroupConfig), - removeChannels: endpointCreator.bind(this, modules, removeChannelsChannelGroupConfig), - deleteGroup: endpointCreator.bind(this, modules, deleteChannelGroupConfig), - }; - /* push */ - this.push = { - addChannels: endpointCreator.bind(this, modules, addPushChannelsConfig), - removeChannels: endpointCreator.bind(this, modules, removePushChannelsConfig), - deleteDevice: endpointCreator.bind(this, modules, removeDevicePushConfig), - listChannels: endpointCreator.bind(this, modules, listPushChannelsConfig), - }; - /* presence */ - this.hereNow = endpointCreator.bind(this, modules, presenceHereNowConfig); - this.whereNow = endpointCreator.bind(this, modules, presenceWhereNowEndpointConfig); - this.getState = endpointCreator.bind(this, modules, presenceGetStateConfig); - /* PAM */ - this.grant = endpointCreator.bind(this, modules, grantEndpointConfig); - this.grantToken = endpointCreator.bind(this, modules, grantTokenEndpointConfig); - this.audit = endpointCreator.bind(this, modules, auditEndpointConfig); - this.revokeToken = endpointCreator.bind(this, modules, endpoint$2); - this.publish = endpointCreator.bind(this, modules, publishEndpointConfig); - this.fire = function (args, callback) { - args.replicate = false; - args.storeInHistory = false; - return _this.publish(args, callback); - }; - this.signal = endpointCreator.bind(this, modules, signalEndpointConfig); - this.history = endpointCreator.bind(this, modules, historyEndpointConfig); - this.deleteMessages = endpointCreator.bind(this, modules, deleteMessagesEndpointConfig); - this.messageCounts = endpointCreator.bind(this, modules, messageCountsEndpointConfig); - this.fetchMessages = endpointCreator.bind(this, modules, fetchMessagesEndpointConfig); - // Actions API - this.addMessageAction = endpointCreator.bind(this, modules, addMessageActionEndpointConfig); - this.removeMessageAction = endpointCreator.bind(this, modules, removeMessageActionEndpointConfig); - this.getMessageActions = endpointCreator.bind(this, modules, getMessageActionEndpointConfig); - // File Upload API v1 - this.listFiles = endpointCreator.bind(this, modules, endpoint$j); - var generateUploadUrl = endpointCreator.bind(this, modules, endpoint$i); - this.publishFile = endpointCreator.bind(this, modules, endpoint$h); - this.sendFile = sendFileFunction({ - generateUploadUrl: generateUploadUrl, - publishFile: this.publishFile, - modules: modules, - }); - this.getFileUrl = function (params) { return getFileUrlFunction(modules, params); }; - this.downloadFile = endpointCreator.bind(this, modules, endpoint$g); - this.deleteFile = endpointCreator.bind(this, modules, endpoint$f); - // Objects API v2 - this.objects = { - getAllUUIDMetadata: endpointCreator.bind(this, modules, endpoint$e), - getUUIDMetadata: endpointCreator.bind(this, modules, endpoint$d), - setUUIDMetadata: endpointCreator.bind(this, modules, endpoint$c), - removeUUIDMetadata: endpointCreator.bind(this, modules, endpoint$b), - getAllChannelMetadata: endpointCreator.bind(this, modules, endpoint$a), - getChannelMetadata: endpointCreator.bind(this, modules, endpoint$9), - setChannelMetadata: endpointCreator.bind(this, modules, endpoint$8), - removeChannelMetadata: endpointCreator.bind(this, modules, endpoint$7), - getChannelMembers: endpointCreator.bind(this, modules, endpoint$6), - setChannelMembers: function (parameters) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } - return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, - modules, - endpoint$5, __assign({ type: 'set' }, parameters)], __read(rest), false)); - }, - removeChannelMembers: function (parameters) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } - return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, - modules, - endpoint$5, __assign({ type: 'delete' }, parameters)], __read(rest), false)); - }, - getMemberships: endpointCreator.bind(this, modules, endpoint$4), - setMemberships: function (parameters) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } - return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, - modules, - endpoint$3, __assign({ type: 'set' }, parameters)], __read(rest), false)); - }, - removeMemberships: function (parameters) { - var rest = []; - for (var _i = 1; _i < arguments.length; _i++) { - rest[_i - 1] = arguments[_i]; - } - return endpointCreator.call.apply(endpointCreator, __spreadArray([_this, - modules, - endpoint$3, __assign({ type: 'delete' }, parameters)], __read(rest), false)); - }, - }; - // User Apis - this.createUser = function (args) { - return _this.objects.setUUIDMetadata({ - uuid: args.userId, - data: args.data, - include: args.include, - }); - }; - this.updateUser = this.createUser; - this.removeUser = function (args) { - return _this.objects.removeUUIDMetadata({ - uuid: args === null || args === void 0 ? void 0 : args.userId, - }); - }; - this.fetchUser = function (args) { - return _this.objects.getUUIDMetadata({ - uuid: args === null || args === void 0 ? void 0 : args.userId, - include: args === null || args === void 0 ? void 0 : args.include, - }); - }; - this.fetchUsers = this.objects.getAllUUIDMetadata; - // Space apis - this.createSpace = function (args) { - return _this.objects.setChannelMetadata({ - channel: args.spaceId, - data: args.data, - include: args.include, - }); - }; - this.updateSpace = this.createSpace; - this.removeSpace = function (args) { - return _this.objects.removeChannelMetadata({ - channel: args.spaceId, - }); - }; - this.fetchSpace = function (args) { - return _this.objects.getChannelMetadata({ - channel: args.spaceId, - include: args.include, - }); - }; - this.fetchSpaces = this.objects.getAllChannelMetadata; - // Membership apis - this.addMemberships = function (parameters) { - var _a, _b; - if (typeof parameters.spaceId === 'string') { - return _this.objects.setChannelMembers({ - channel: parameters.spaceId, - uuids: (_a = parameters.users) === null || _a === void 0 ? void 0 : _a.map(function (user) { - if (typeof user === 'string') { - return user; - } - return { - id: user.userId, - custom: user.custom, - status: user.status, - }; - }), - limit: 0, - }); - } - else { - return _this.objects.setMemberships({ - uuid: parameters.userId, - channels: (_b = parameters.spaces) === null || _b === void 0 ? void 0 : _b.map(function (space) { - if (typeof space === 'string') { - return space; - } - return { - id: space.spaceId, - custom: space.custom, - status: space.status, - }; - }), - limit: 0, - }); - } - }; - this.updateMemberships = this.addMemberships; - this.removeMemberships = function (parameters) { - if (typeof parameters.spaceId === 'string') { - return _this.objects.removeChannelMembers({ - channel: parameters.spaceId, - uuids: parameters.userIds, - limit: 0, - }); - } - else { - return _this.objects.removeMemberships({ - uuid: parameters.userId, - channels: parameters.spaceIds, - limit: 0, - }); - } - }; - this.fetchMemberships = function (params) { - if (typeof params.spaceId === 'string') { - return _this.objects - .getChannelMembers({ - channel: params.spaceId, - filter: params.filter, - limit: params.limit, - page: params.page, - include: { - customFields: params.include.customFields, - UUIDFields: params.include.userFields, - customUUIDFields: params.include.customUserFields, - totalCount: params.include.totalCount, - }, - sort: params.sort != null - ? Object.fromEntries(Object.entries(params.sort).map(function (_a) { - var _b = __read(_a, 2), k = _b[0], v = _b[1]; - return [k.replace('user', 'uuid'), v]; - })) - : null, - }) - .then(function (res) { - var _a; - res.data = (_a = res.data) === null || _a === void 0 ? void 0 : _a.map(function (m) { - return { - user: m.uuid, - custom: m.custom, - updated: m.updated, - eTag: m.eTag, - }; - }); - return res; - }); - } - else { - return _this.objects - .getMemberships({ - uuid: params.userId, - filter: params.filter, - limit: params.limit, - page: params.page, - include: { - customFields: params.include.customFields, - channelFields: params.include.spaceFields, - customChannelFields: params.include.customSpaceFields, - totalCount: params.include.totalCount, - }, - sort: params.sort != null - ? Object.fromEntries(Object.entries(params.sort).map(function (_a) { - var _b = __read(_a, 2), k = _b[0], v = _b[1]; - return [k.replace('space', 'channel'), v]; - })) - : null, - }) - .then(function (res) { - var _a; - res.data = (_a = res.data) === null || _a === void 0 ? void 0 : _a.map(function (m) { - return { - space: m.channel, - custom: m.custom, - updated: m.updated, - eTag: m.eTag, - }; - }); - return res; - }); - } - }; - this.time = timeEndpoint; - // --- deprecated ------------------ - this.stop = this.destroy; // -------- - // --- deprecated ------------------ - // mount crypto - this.encrypt = crypto.encrypt.bind(crypto); - this.decrypt = crypto.decrypt.bind(crypto); - /* config */ - this.getAuthKey = modules.config.getAuthKey.bind(modules.config); - this.setAuthKey = modules.config.setAuthKey.bind(modules.config); - this.setCipherKey = modules.config.setCipherKey.bind(modules.config); - this.getUUID = modules.config.getUUID.bind(modules.config); - this.setUUID = modules.config.setUUID.bind(modules.config); - this.getFilterExpression = modules.config.getFilterExpression.bind(modules.config); - this.setFilterExpression = modules.config.setFilterExpression.bind(modules.config); - this.setHeartbeatInterval = modules.config.setHeartbeatInterval.bind(modules.config); - if (networking.hasModule('proxy')) { - this.setProxy = function (proxy) { - modules.config.setProxy(proxy); - _this.reconnect(); - }; - } - } - default_1.prototype.getVersion = function () { - return this._config.getVersion(); - }; - default_1.prototype._addPnsdkSuffix = function (name, suffix) { - this._config._addPnsdkSuffix(name, suffix); - }; - // network hooks to indicate network changes - default_1.prototype.networkDownDetected = function () { - this._listenerManager.announceNetworkDown(); - if (this._config.restore) { - this.disconnect(); - } - else { - this.destroy(true); - } - }; - default_1.prototype.networkUpDetected = function () { - this._listenerManager.announceNetworkUp(); - this.reconnect(); - }; - default_1.notificationPayload = function (title, body) { - return new NotificationsPayload(title, body); - }; - default_1.generateUUID = function () { - return uuidGenerator.createUUID(); - }; - default_1.OPERATIONS = OPERATIONS; - default_1.CATEGORIES = categories; - return default_1; - }()); - - /* */ - var default_1$2 = /** @class */ (function () { - function default_1(modules) { - var _this = this; - this._modules = {}; - Object.keys(modules).forEach(function (key) { - _this._modules[key] = modules[key].bind(_this); - }); - } - default_1.prototype.init = function (config) { - this._config = config; - if (Array.isArray(this._config.origin)) { - this._currentSubDomain = Math.floor(Math.random() * this._config.origin.length); - } - else { - this._currentSubDomain = 0; - } - this._coreParams = {}; - // create initial origins - this.shiftStandardOrigin(); - }; - default_1.prototype.nextOrigin = function () { - var protocol = this._config.secure ? 'https://' : 'http://'; - if (typeof this._config.origin === 'string') { - return "".concat(protocol).concat(this._config.origin); - } - this._currentSubDomain += 1; - if (this._currentSubDomain >= this._config.origin.length) { - this._currentSubDomain = 0; - } - var origin = this._config.origin[this._currentSubDomain]; - return "".concat(protocol).concat(origin); - }; - default_1.prototype.hasModule = function (name) { - return name in this._modules; - }; - // origin operations - default_1.prototype.shiftStandardOrigin = function () { - this._standardOrigin = this.nextOrigin(); - return this._standardOrigin; - }; - default_1.prototype.getStandardOrigin = function () { - return this._standardOrigin; - }; - default_1.prototype.POSTFILE = function (url, fields, file) { - return this._modules.postfile(url, fields, file); - }; - default_1.prototype.GETFILE = function (params, endpoint, callback) { - return this._modules.getfile(params, endpoint, callback); - }; - default_1.prototype.POST = function (params, body, endpoint, callback) { - return this._modules.post(params, body, endpoint, callback); - }; - default_1.prototype.PATCH = function (params, body, endpoint, callback) { - return this._modules.patch(params, body, endpoint, callback); - }; - default_1.prototype.GET = function (params, endpoint, callback) { - return this._modules.get(params, endpoint, callback); - }; - default_1.prototype.DELETE = function (params, endpoint, callback) { - return this._modules.del(params, endpoint, callback); - }; - default_1.prototype._detectErrorCategory = function (err) { - if (err.code === 'ENOTFOUND') { - return categories.PNNetworkIssuesCategory; - } - if (err.code === 'ECONNREFUSED') { - return categories.PNNetworkIssuesCategory; - } - if (err.code === 'ECONNRESET') { - return categories.PNNetworkIssuesCategory; - } - if (err.code === 'EAI_AGAIN') { - return categories.PNNetworkIssuesCategory; - } - if (err.status === 0 || (err.hasOwnProperty('status') && typeof err.status === 'undefined')) { - return categories.PNNetworkIssuesCategory; - } - if (err.timeout) - return categories.PNTimeoutCategory; - if (err.code === 'ETIMEDOUT') { - return categories.PNNetworkIssuesCategory; - } - if (err.response) { - if (err.response.badRequest) { - return categories.PNBadRequestCategory; - } - if (err.response.forbidden) { - return categories.PNAccessDeniedCategory; - } - } - return categories.PNUnknownCategory; - }; - return default_1; - }()); - - function stringifyBufferKeys(obj) { - var isObject = function (value) { return value && typeof value === 'object' && value.constructor === Object; }; - var isString = function (value) { return typeof value === 'string' || value instanceof String; }; - var isNumber = function (value) { return typeof value === 'number' && isFinite(value); }; - if (!isObject(obj)) { - return obj; - } - var normalizedObject = {}; - Object.keys(obj).forEach(function (key) { - var keyIsString = isString(key); - var stringifiedKey = key; - var value = obj[key]; - if (Array.isArray(key) || (keyIsString && key.indexOf(',') >= 0)) { - var bytes = keyIsString ? key.split(',') : key; - stringifiedKey = bytes.reduce(function (string, byte) { - string += String.fromCharCode(byte); - return string; - }, ''); - } - else if (isNumber(key) || (keyIsString && !isNaN(key))) { - stringifiedKey = String.fromCharCode(keyIsString ? parseInt(key, 10) : 10); - } - normalizedObject[stringifiedKey] = isObject(value) ? stringifyBufferKeys(value) : value; - }); - return normalizedObject; - } - - var default_1$1 = /** @class */ (function () { - function default_1(decode, base64ToBinary) { - this._base64ToBinary = base64ToBinary; - this._decode = decode; - } - default_1.prototype.decodeToken = function (tokenString) { - var padding = ''; - if (tokenString.length % 4 === 3) { - padding = '='; - } - else if (tokenString.length % 4 === 2) { - padding = '=='; - } - var cleaned = tokenString.replace(/-/gi, '+').replace(/_/gi, '/') + padding; - var result = this._decode(this._base64ToBinary(cleaned)); - if (typeof result === 'object') { - return result; - } - return undefined; - }; - return default_1; - }()); - - var client = {exports: {}}; - - var componentEmitter = {exports: {}}; - - (function (module) { - /** - * Expose `Emitter`. - */ - - { - module.exports = Emitter; - } - - /** - * Initialize a new `Emitter`. - * - * @api public - */ - - function Emitter(obj) { - if (obj) return mixin(obj); - } - /** - * Mixin the emitter properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - - function mixin(obj) { - for (var key in Emitter.prototype) { - obj[key] = Emitter.prototype[key]; - } - return obj; - } - - /** - * Listen on the given `event` with `fn`. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - - Emitter.prototype.on = - Emitter.prototype.addEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - (this._callbacks['$' + event] = this._callbacks['$' + event] || []) - .push(fn); - return this; - }; - - /** - * Adds an `event` listener that will be invoked a single - * time then automatically removed. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - - Emitter.prototype.once = function(event, fn){ - function on() { - this.off(event, on); - fn.apply(this, arguments); - } - - on.fn = fn; - this.on(event, on); - return this; - }; - - /** - * Remove the given callback for `event` or all - * registered callbacks. - * - * @param {String} event - * @param {Function} fn - * @return {Emitter} - * @api public - */ - - Emitter.prototype.off = - Emitter.prototype.removeListener = - Emitter.prototype.removeAllListeners = - Emitter.prototype.removeEventListener = function(event, fn){ - this._callbacks = this._callbacks || {}; - - // all - if (0 == arguments.length) { - this._callbacks = {}; - return this; - } - - // specific event - var callbacks = this._callbacks['$' + event]; - if (!callbacks) return this; - - // remove all handlers - if (1 == arguments.length) { - delete this._callbacks['$' + event]; - return this; - } - - // remove specific handler - var cb; - for (var i = 0; i < callbacks.length; i++) { - cb = callbacks[i]; - if (cb === fn || cb.fn === fn) { - callbacks.splice(i, 1); - break; - } - } - - // Remove event specific arrays for event types that no - // one is subscribed for to avoid memory leak. - if (callbacks.length === 0) { - delete this._callbacks['$' + event]; - } - - return this; - }; - - /** - * Emit `event` with the given args. - * - * @param {String} event - * @param {Mixed} ... - * @return {Emitter} - */ - - Emitter.prototype.emit = function(event){ - this._callbacks = this._callbacks || {}; - - var args = new Array(arguments.length - 1) - , callbacks = this._callbacks['$' + event]; - - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - - if (callbacks) { - callbacks = callbacks.slice(0); - for (var i = 0, len = callbacks.length; i < len; ++i) { - callbacks[i].apply(this, args); - } - } - - return this; - }; - - /** - * Return array of callbacks for `event`. - * - * @param {String} event - * @return {Array} - * @api public - */ - - Emitter.prototype.listeners = function(event){ - this._callbacks = this._callbacks || {}; - return this._callbacks['$' + event] || []; - }; - - /** - * Check if this emitter has `event` handlers. - * - * @param {String} event - * @return {Boolean} - * @api public - */ - - Emitter.prototype.hasListeners = function(event){ - return !! this.listeners(event).length; - }; - }(componentEmitter)); - - var fastSafeStringify = stringify$2; - stringify$2.default = stringify$2; - stringify$2.stable = deterministicStringify; - stringify$2.stableStringify = deterministicStringify; - - var LIMIT_REPLACE_NODE = '[...]'; - var CIRCULAR_REPLACE_NODE = '[Circular]'; - - var arr = []; - var replacerStack = []; - - function defaultOptions () { - return { - depthLimit: Number.MAX_SAFE_INTEGER, - edgesLimit: Number.MAX_SAFE_INTEGER - } - } - - // Regular stringify - function stringify$2 (obj, replacer, spacer, options) { - if (typeof options === 'undefined') { - options = defaultOptions(); - } - - decirc(obj, '', 0, [], undefined, 0, options); - var res; - try { - if (replacerStack.length === 0) { - res = JSON.stringify(obj, replacer, spacer); - } else { - res = JSON.stringify(obj, replaceGetterValues(replacer), spacer); - } - } catch (_) { - return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]') - } finally { - while (arr.length !== 0) { - var part = arr.pop(); - if (part.length === 4) { - Object.defineProperty(part[0], part[1], part[3]); - } else { - part[0][part[1]] = part[2]; - } - } - } - return res - } - - function setReplace (replace, val, k, parent) { - var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k); - if (propertyDescriptor.get !== undefined) { - if (propertyDescriptor.configurable) { - Object.defineProperty(parent, k, { value: replace }); - arr.push([parent, k, val, propertyDescriptor]); - } else { - replacerStack.push([val, k, replace]); - } - } else { - parent[k] = replace; - arr.push([parent, k, val]); - } - } - - function decirc (val, k, edgeIndex, stack, parent, depth, options) { - depth += 1; - var i; - if (typeof val === 'object' && val !== null) { - for (i = 0; i < stack.length; i++) { - if (stack[i] === val) { - setReplace(CIRCULAR_REPLACE_NODE, val, k, parent); - return - } - } - - if ( - typeof options.depthLimit !== 'undefined' && - depth > options.depthLimit - ) { - setReplace(LIMIT_REPLACE_NODE, val, k, parent); - return - } - - if ( - typeof options.edgesLimit !== 'undefined' && - edgeIndex + 1 > options.edgesLimit - ) { - setReplace(LIMIT_REPLACE_NODE, val, k, parent); - return - } - - stack.push(val); - // Optimize for Arrays. Big arrays could kill the performance otherwise! - if (Array.isArray(val)) { - for (i = 0; i < val.length; i++) { - decirc(val[i], i, i, stack, val, depth, options); - } - } else { - var keys = Object.keys(val); - for (i = 0; i < keys.length; i++) { - var key = keys[i]; - decirc(val[key], key, i, stack, val, depth, options); - } - } - stack.pop(); - } - } - - // Stable-stringify - function compareFunction (a, b) { - if (a < b) { - return -1 - } - if (a > b) { - return 1 - } - return 0 - } - - function deterministicStringify (obj, replacer, spacer, options) { - if (typeof options === 'undefined') { - options = defaultOptions(); - } - - var tmp = deterministicDecirc(obj, '', 0, [], undefined, 0, options) || obj; - var res; - try { - if (replacerStack.length === 0) { - res = JSON.stringify(tmp, replacer, spacer); - } else { - res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer); - } - } catch (_) { - return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]') - } finally { - // Ensure that we restore the object as it was. - while (arr.length !== 0) { - var part = arr.pop(); - if (part.length === 4) { - Object.defineProperty(part[0], part[1], part[3]); - } else { - part[0][part[1]] = part[2]; - } - } - } - return res - } - - function deterministicDecirc (val, k, edgeIndex, stack, parent, depth, options) { - depth += 1; - var i; - if (typeof val === 'object' && val !== null) { - for (i = 0; i < stack.length; i++) { - if (stack[i] === val) { - setReplace(CIRCULAR_REPLACE_NODE, val, k, parent); - return - } - } - try { - if (typeof val.toJSON === 'function') { - return - } - } catch (_) { - return - } - - if ( - typeof options.depthLimit !== 'undefined' && - depth > options.depthLimit - ) { - setReplace(LIMIT_REPLACE_NODE, val, k, parent); - return - } - - if ( - typeof options.edgesLimit !== 'undefined' && - edgeIndex + 1 > options.edgesLimit - ) { - setReplace(LIMIT_REPLACE_NODE, val, k, parent); - return - } - - stack.push(val); - // Optimize for Arrays. Big arrays could kill the performance otherwise! - if (Array.isArray(val)) { - for (i = 0; i < val.length; i++) { - deterministicDecirc(val[i], i, i, stack, val, depth, options); - } - } else { - // Create a temporary object in the required way - var tmp = {}; - var keys = Object.keys(val).sort(compareFunction); - for (i = 0; i < keys.length; i++) { - var key = keys[i]; - deterministicDecirc(val[key], key, i, stack, val, depth, options); - tmp[key] = val[key]; - } - if (typeof parent !== 'undefined') { - arr.push([parent, k, val]); - parent[k] = tmp; - } else { - return tmp - } - } - stack.pop(); - } - } - - // wraps replacer function to handle values we couldn't replace - // and mark them as replaced value - function replaceGetterValues (replacer) { - replacer = - typeof replacer !== 'undefined' - ? replacer - : function (k, v) { - return v - }; - return function (key, val) { - if (replacerStack.length > 0) { - for (var i = 0; i < replacerStack.length; i++) { - var part = replacerStack[i]; - if (part[1] === key && part[0] === val) { - val = part[2]; - replacerStack.splice(i, 1); - break - } - } - } - return replacer.call(this, key, val) - } - } - - var replace = String.prototype.replace; - var percentTwenties = /%20/g; - - var Format = { - RFC1738: 'RFC1738', - RFC3986: 'RFC3986' - }; - - var formats$3 = { - 'default': Format.RFC3986, - formatters: { - RFC1738: function (value) { - return replace.call(value, percentTwenties, '+'); - }, - RFC3986: function (value) { - return String(value); - } - }, - RFC1738: Format.RFC1738, - RFC3986: Format.RFC3986 - }; - - var formats$2 = formats$3; - - var has$2 = Object.prototype.hasOwnProperty; - var isArray$2 = Array.isArray; - - var hexTable = (function () { - var array = []; - for (var i = 0; i < 256; ++i) { - array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); - } - - return array; - }()); - - var compactQueue = function compactQueue(queue) { - while (queue.length > 1) { - var item = queue.pop(); - var obj = item.obj[item.prop]; - - if (isArray$2(obj)) { - var compacted = []; - - for (var j = 0; j < obj.length; ++j) { - if (typeof obj[j] !== 'undefined') { - compacted.push(obj[j]); - } - } - - item.obj[item.prop] = compacted; - } - } - }; - - var arrayToObject = function arrayToObject(source, options) { - var obj = options && options.plainObjects ? Object.create(null) : {}; - for (var i = 0; i < source.length; ++i) { - if (typeof source[i] !== 'undefined') { - obj[i] = source[i]; - } - } - - return obj; - }; - - var merge = function merge(target, source, options) { - /* eslint no-param-reassign: 0 */ - if (!source) { - return target; - } - - if (typeof source !== 'object') { - if (isArray$2(target)) { - target.push(source); - } else if (target && typeof target === 'object') { - if ((options && (options.plainObjects || options.allowPrototypes)) || !has$2.call(Object.prototype, source)) { - target[source] = true; - } - } else { - return [target, source]; - } - - return target; - } - - if (!target || typeof target !== 'object') { - return [target].concat(source); - } - - var mergeTarget = target; - if (isArray$2(target) && !isArray$2(source)) { - mergeTarget = arrayToObject(target, options); - } - - if (isArray$2(target) && isArray$2(source)) { - source.forEach(function (item, i) { - if (has$2.call(target, i)) { - var targetItem = target[i]; - if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { - target[i] = merge(targetItem, item, options); - } else { - target.push(item); - } - } else { - target[i] = item; - } - }); - return target; - } - - return Object.keys(source).reduce(function (acc, key) { - var value = source[key]; - - if (has$2.call(acc, key)) { - acc[key] = merge(acc[key], value, options); - } else { - acc[key] = value; - } - return acc; - }, mergeTarget); - }; - - var assign = function assignSingleSource(target, source) { - return Object.keys(source).reduce(function (acc, key) { - acc[key] = source[key]; - return acc; - }, target); - }; - - var decode = function (str, decoder, charset) { - var strWithoutPlus = str.replace(/\+/g, ' '); - if (charset === 'iso-8859-1') { - // unescape never throws, no try...catch needed: - return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); - } - // utf-8 - try { - return decodeURIComponent(strWithoutPlus); - } catch (e) { - return strWithoutPlus; - } - }; - - var encode = function encode(str, defaultEncoder, charset, kind, format) { - // This code was originally written by Brian White (mscdex) for the io.js core querystring library. - // It has been adapted here for stricter adherence to RFC 3986 - if (str.length === 0) { - return str; - } - - var string = str; - if (typeof str === 'symbol') { - string = Symbol.prototype.toString.call(str); - } else if (typeof str !== 'string') { - string = String(str); - } - - if (charset === 'iso-8859-1') { - return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { - return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; - }); - } - - var out = ''; - for (var i = 0; i < string.length; ++i) { - var c = string.charCodeAt(i); - - if ( - c === 0x2D // - - || c === 0x2E // . - || c === 0x5F // _ - || c === 0x7E // ~ - || (c >= 0x30 && c <= 0x39) // 0-9 - || (c >= 0x41 && c <= 0x5A) // a-z - || (c >= 0x61 && c <= 0x7A) // A-Z - || (format === formats$2.RFC1738 && (c === 0x28 || c === 0x29)) // ( ) - ) { - out += string.charAt(i); - continue; - } - - if (c < 0x80) { - out = out + hexTable[c]; - continue; - } - - if (c < 0x800) { - out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - if (c < 0xD800 || c >= 0xE000) { - out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - i += 1; - c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - /* eslint operator-linebreak: [2, "before"] */ - out += hexTable[0xF0 | (c >> 18)] - + hexTable[0x80 | ((c >> 12) & 0x3F)] - + hexTable[0x80 | ((c >> 6) & 0x3F)] - + hexTable[0x80 | (c & 0x3F)]; - } - - return out; - }; - - var compact = function compact(value) { - var queue = [{ obj: { o: value }, prop: 'o' }]; - var refs = []; - - for (var i = 0; i < queue.length; ++i) { - var item = queue[i]; - var obj = item.obj[item.prop]; - - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - var val = obj[key]; - if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { - queue.push({ obj: obj, prop: key }); - refs.push(val); - } - } - } - - compactQueue(queue); - - return value; - }; - - var isRegExp = function isRegExp(obj) { - return Object.prototype.toString.call(obj) === '[object RegExp]'; - }; - - var isBuffer = function isBuffer(obj) { - if (!obj || typeof obj !== 'object') { - return false; - } - - return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); - }; - - var combine = function combine(a, b) { - return [].concat(a, b); - }; - - var maybeMap = function maybeMap(val, fn) { - if (isArray$2(val)) { - var mapped = []; - for (var i = 0; i < val.length; i += 1) { - mapped.push(fn(val[i])); - } - return mapped; - } - return fn(val); - }; - - var utils$4 = { - arrayToObject: arrayToObject, - assign: assign, - combine: combine, - compact: compact, - decode: decode, - encode: encode, - isBuffer: isBuffer, - isRegExp: isRegExp, - maybeMap: maybeMap, - merge: merge - }; - - var utils$3 = utils$4; - var formats$1 = formats$3; - var has$1 = Object.prototype.hasOwnProperty; - - var arrayPrefixGenerators = { - brackets: function brackets(prefix) { - return prefix + '[]'; - }, - comma: 'comma', - indices: function indices(prefix, key) { - return prefix + '[' + key + ']'; - }, - repeat: function repeat(prefix) { - return prefix; - } - }; - - var isArray$1 = Array.isArray; - var split = String.prototype.split; - var push = Array.prototype.push; - var pushToArray = function (arr, valueOrArray) { - push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]); - }; - - var toISO = Date.prototype.toISOString; - - var defaultFormat = formats$1['default']; - var defaults$1 = { - addQueryPrefix: false, - allowDots: false, - charset: 'utf-8', - charsetSentinel: false, - delimiter: '&', - encode: true, - encoder: utils$3.encode, - encodeValuesOnly: false, - format: defaultFormat, - formatter: formats$1.formatters[defaultFormat], - // deprecated - indices: false, - serializeDate: function serializeDate(date) { - return toISO.call(date); - }, - skipNulls: false, - strictNullHandling: false - }; - - var isNonNullishPrimitive = function isNonNullishPrimitive(v) { - return typeof v === 'string' - || typeof v === 'number' - || typeof v === 'boolean' - || typeof v === 'symbol' - || typeof v === 'bigint'; - }; - - var stringify$1 = function stringify( - object, - prefix, - generateArrayPrefix, - strictNullHandling, - skipNulls, - encoder, - filter, - sort, - allowDots, - serializeDate, - format, - formatter, - encodeValuesOnly, - charset - ) { - var obj = object; - if (typeof filter === 'function') { - obj = filter(prefix, obj); - } else if (obj instanceof Date) { - obj = serializeDate(obj); - } else if (generateArrayPrefix === 'comma' && isArray$1(obj)) { - obj = utils$3.maybeMap(obj, function (value) { - if (value instanceof Date) { - return serializeDate(value); - } - return value; - }); - } - - if (obj === null) { - if (strictNullHandling) { - return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder, charset, 'key', format) : prefix; - } - - obj = ''; - } - - if (isNonNullishPrimitive(obj) || utils$3.isBuffer(obj)) { - if (encoder) { - var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder, charset, 'key', format); - if (generateArrayPrefix === 'comma' && encodeValuesOnly) { - var valuesArray = split.call(String(obj), ','); - var valuesJoined = ''; - for (var i = 0; i < valuesArray.length; ++i) { - valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults$1.encoder, charset, 'value', format)); - } - return [formatter(keyValue) + '=' + valuesJoined]; - } - return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$1.encoder, charset, 'value', format))]; - } - return [formatter(prefix) + '=' + formatter(String(obj))]; - } - - var values = []; - - if (typeof obj === 'undefined') { - return values; - } - - var objKeys; - if (generateArrayPrefix === 'comma' && isArray$1(obj)) { - // we need to join elements in - objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }]; - } else if (isArray$1(filter)) { - objKeys = filter; - } else { - var keys = Object.keys(obj); - objKeys = sort ? keys.sort(sort) : keys; - } - - for (var j = 0; j < objKeys.length; ++j) { - var key = objKeys[j]; - var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key]; - - if (skipNulls && value === null) { - continue; - } - - var keyPrefix = isArray$1(obj) - ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix - : prefix + (allowDots ? '.' + key : '[' + key + ']'); - - pushToArray(values, stringify( - value, - keyPrefix, - generateArrayPrefix, - strictNullHandling, - skipNulls, - encoder, - filter, - sort, - allowDots, - serializeDate, - format, - formatter, - encodeValuesOnly, - charset - )); - } - - return values; - }; - - var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { - if (!opts) { - return defaults$1; - } - - if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - - var charset = opts.charset || defaults$1.charset; - if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { - throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); - } - - var format = formats$1['default']; - if (typeof opts.format !== 'undefined') { - if (!has$1.call(formats$1.formatters, opts.format)) { - throw new TypeError('Unknown format option provided.'); - } - format = opts.format; - } - var formatter = formats$1.formatters[format]; - - var filter = defaults$1.filter; - if (typeof opts.filter === 'function' || isArray$1(opts.filter)) { - filter = opts.filter; - } - - return { - addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$1.addQueryPrefix, - allowDots: typeof opts.allowDots === 'undefined' ? defaults$1.allowDots : !!opts.allowDots, - charset: charset, - charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel, - delimiter: typeof opts.delimiter === 'undefined' ? defaults$1.delimiter : opts.delimiter, - encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$1.encode, - encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$1.encoder, - encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults$1.encodeValuesOnly, - filter: filter, - format: format, - formatter: formatter, - serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$1.serializeDate, - skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$1.skipNulls, - sort: typeof opts.sort === 'function' ? opts.sort : null, - strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$1.strictNullHandling - }; - }; - - var stringify_1 = function (object, opts) { - var obj = object; - var options = normalizeStringifyOptions(opts); - - var objKeys; - var filter; - - if (typeof options.filter === 'function') { - filter = options.filter; - obj = filter('', obj); - } else if (isArray$1(options.filter)) { - filter = options.filter; - objKeys = filter; - } - - var keys = []; - - if (typeof obj !== 'object' || obj === null) { - return ''; - } - - var arrayFormat; - if (opts && opts.arrayFormat in arrayPrefixGenerators) { - arrayFormat = opts.arrayFormat; - } else if (opts && 'indices' in opts) { - arrayFormat = opts.indices ? 'indices' : 'repeat'; - } else { - arrayFormat = 'indices'; - } - - var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; - - if (!objKeys) { - objKeys = Object.keys(obj); - } - - if (options.sort) { - objKeys.sort(options.sort); - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (options.skipNulls && obj[key] === null) { - continue; - } - pushToArray(keys, stringify$1( - obj[key], - key, - generateArrayPrefix, - options.strictNullHandling, - options.skipNulls, - options.encode ? options.encoder : null, - options.filter, - options.sort, - options.allowDots, - options.serializeDate, - options.format, - options.formatter, - options.encodeValuesOnly, - options.charset - )); - } - - var joined = keys.join(options.delimiter); - var prefix = options.addQueryPrefix === true ? '?' : ''; - - if (options.charsetSentinel) { - if (options.charset === 'iso-8859-1') { - // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark - prefix += 'utf8=%26%2310003%3B&'; - } else { - // encodeURIComponent('✓') - prefix += 'utf8=%E2%9C%93&'; - } - } - - return joined.length > 0 ? prefix + joined : ''; - }; - - var utils$2 = utils$4; - - var has = Object.prototype.hasOwnProperty; - var isArray = Array.isArray; - - var defaults = { - allowDots: false, - allowPrototypes: false, - arrayLimit: 20, - charset: 'utf-8', - charsetSentinel: false, - comma: false, - decoder: utils$2.decode, - delimiter: '&', - depth: 5, - ignoreQueryPrefix: false, - interpretNumericEntities: false, - parameterLimit: 1000, - parseArrays: true, - plainObjects: false, - strictNullHandling: false - }; - - var interpretNumericEntities = function (str) { - return str.replace(/&#(\d+);/g, function ($0, numberStr) { - return String.fromCharCode(parseInt(numberStr, 10)); - }); - }; - - var parseArrayValue = function (val, options) { - if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) { - return val.split(','); - } - - return val; - }; - - // This is what browsers will submit when the ✓ character occurs in an - // application/x-www-form-urlencoded body and the encoding of the page containing - // the form is iso-8859-1, or when the submitted form has an accept-charset - // attribute of iso-8859-1. Presumably also with other charsets that do not contain - // the ✓ character, such as us-ascii. - var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓') - - // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded. - var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓') - - var parseValues = function parseQueryStringValues(str, options) { - var obj = {}; - var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; - var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; - var parts = cleanStr.split(options.delimiter, limit); - var skipIndex = -1; // Keep track of where the utf8 sentinel was found - var i; - - var charset = options.charset; - if (options.charsetSentinel) { - for (i = 0; i < parts.length; ++i) { - if (parts[i].indexOf('utf8=') === 0) { - if (parts[i] === charsetSentinel) { - charset = 'utf-8'; - } else if (parts[i] === isoSentinel) { - charset = 'iso-8859-1'; - } - skipIndex = i; - i = parts.length; // The eslint settings do not allow break; - } - } - } - - for (i = 0; i < parts.length; ++i) { - if (i === skipIndex) { - continue; - } - var part = parts[i]; - - var bracketEqualsPos = part.indexOf(']='); - var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; - - var key, val; - if (pos === -1) { - key = options.decoder(part, defaults.decoder, charset, 'key'); - val = options.strictNullHandling ? null : ''; - } else { - key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key'); - val = utils$2.maybeMap( - parseArrayValue(part.slice(pos + 1), options), - function (encodedVal) { - return options.decoder(encodedVal, defaults.decoder, charset, 'value'); - } - ); - } - - if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { - val = interpretNumericEntities(val); - } - - if (part.indexOf('[]=') > -1) { - val = isArray(val) ? [val] : val; - } - - if (has.call(obj, key)) { - obj[key] = utils$2.combine(obj[key], val); - } else { - obj[key] = val; - } - } - - return obj; - }; - - var parseObject = function (chain, val, options, valuesParsed) { - var leaf = valuesParsed ? val : parseArrayValue(val, options); - - for (var i = chain.length - 1; i >= 0; --i) { - var obj; - var root = chain[i]; - - if (root === '[]' && options.parseArrays) { - obj = [].concat(leaf); - } else { - obj = options.plainObjects ? Object.create(null) : {}; - var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; - var index = parseInt(cleanRoot, 10); - if (!options.parseArrays && cleanRoot === '') { - obj = { 0: leaf }; - } else if ( - !isNaN(index) - && root !== cleanRoot - && String(index) === cleanRoot - && index >= 0 - && (options.parseArrays && index <= options.arrayLimit) - ) { - obj = []; - obj[index] = leaf; - } else if (cleanRoot !== '__proto__') { - obj[cleanRoot] = leaf; - } - } - - leaf = obj; - } - - return leaf; - }; - - var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) { - if (!givenKey) { - return; - } - - // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; - - // The regex chunks - - var brackets = /(\[[^[\]]*])/; - var child = /(\[[^[\]]*])/g; - - // Get the parent - - var segment = options.depth > 0 && brackets.exec(key); - var parent = segment ? key.slice(0, segment.index) : key; - - // Stash the parent if it exists - - var keys = []; - if (parent) { - // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties - if (!options.plainObjects && has.call(Object.prototype, parent)) { - if (!options.allowPrototypes) { - return; - } - } - - keys.push(parent); - } - - // Loop through children appending to the array until we hit depth - - var i = 0; - while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) { - i += 1; - if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { - if (!options.allowPrototypes) { - return; - } - } - keys.push(segment[1]); - } - - // If there's a remainder, just add whatever is left - - if (segment) { - keys.push('[' + key.slice(segment.index) + ']'); - } - - return parseObject(keys, val, options, valuesParsed); - }; - - var normalizeParseOptions = function normalizeParseOptions(opts) { - if (!opts) { - return defaults; - } - - if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { - throw new TypeError('Decoder has to be a function.'); - } - - if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { - throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); - } - var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; - - return { - allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, - allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, - arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, - charset: charset, - charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, - comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, - decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, - delimiter: typeof opts.delimiter === 'string' || utils$2.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, - // eslint-disable-next-line no-implicit-coercion, no-extra-parens - depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth, - ignoreQueryPrefix: opts.ignoreQueryPrefix === true, - interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, - parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, - parseArrays: opts.parseArrays !== false, - plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, - strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling - }; - }; - - var parse$1 = function (str, opts) { - var options = normalizeParseOptions(opts); - - if (str === '' || str === null || typeof str === 'undefined') { - return options.plainObjects ? Object.create(null) : {}; - } - - var tempObj = typeof str === 'string' ? parseValues(str, options) : str; - var obj = options.plainObjects ? Object.create(null) : {}; - - // Iterate over the keys and setup the new object - - var keys = Object.keys(tempObj); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string'); - obj = utils$2.merge(obj, newObj, options); - } - - return utils$2.compact(obj); - }; - - var stringify = stringify_1; - var parse = parse$1; - var formats = formats$3; - - var lib = { - formats: formats, - parse: parse, - stringify: stringify - }; - - function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); } - - /** - * Check if `obj` is an object. - * - * @param {Object} obj - * @return {Boolean} - * @api private - */ - function isObject$1(obj) { - return obj !== null && _typeof$1(obj) === 'object'; - } - - var isObject_1 = isObject$1; - - function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - - /** - * Module of mixed-in functions shared between node and client code - */ - var isObject = isObject_1; - /** - * Expose `RequestBase`. - */ - - - var requestBase = RequestBase; - /** - * Initialize a new `RequestBase`. - * - * @api public - */ - - function RequestBase(object) { - if (object) return mixin$1(object); - } - /** - * Mixin the prototype properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - - - function mixin$1(object) { - for (var key in RequestBase.prototype) { - if (Object.prototype.hasOwnProperty.call(RequestBase.prototype, key)) object[key] = RequestBase.prototype[key]; - } - - return object; - } - /** - * Clear previous timeout. - * - * @return {Request} for chaining - * @api public - */ - - - RequestBase.prototype.clearTimeout = function () { - clearTimeout(this._timer); - clearTimeout(this._responseTimeoutTimer); - clearTimeout(this._uploadTimeoutTimer); - delete this._timer; - delete this._responseTimeoutTimer; - delete this._uploadTimeoutTimer; - return this; - }; - /** - * Override default response body parser - * - * This function will be called to convert incoming data into request.body - * - * @param {Function} - * @api public - */ - - - RequestBase.prototype.parse = function (fn) { - this._parser = fn; - return this; - }; - /** - * Set format of binary response body. - * In browser valid formats are 'blob' and 'arraybuffer', - * which return Blob and ArrayBuffer, respectively. - * - * In Node all values result in Buffer. - * - * Examples: - * - * req.get('/') - * .responseType('blob') - * .end(callback); - * - * @param {String} val - * @return {Request} for chaining - * @api public - */ - - - RequestBase.prototype.responseType = function (value) { - this._responseType = value; - return this; - }; - /** - * Override default request body serializer - * - * This function will be called to convert data set via .send or .attach into payload to send - * - * @param {Function} - * @api public - */ - - - RequestBase.prototype.serialize = function (fn) { - this._serializer = fn; - return this; - }; - /** - * Set timeouts. - * - * - response timeout is time between sending request and receiving the first byte of the response. Includes DNS and connection time. - * - deadline is the time from start of the request to receiving response body in full. If the deadline is too short large files may not load at all on slow connections. - * - upload is the time since last bit of data was sent or received. This timeout works only if deadline timeout is off - * - * Value of 0 or false means no timeout. - * - * @param {Number|Object} ms or {response, deadline} - * @return {Request} for chaining - * @api public - */ - - - RequestBase.prototype.timeout = function (options) { - if (!options || _typeof(options) !== 'object') { - this._timeout = options; - this._responseTimeout = 0; - this._uploadTimeout = 0; - return this; - } - - for (var option in options) { - if (Object.prototype.hasOwnProperty.call(options, option)) { - switch (option) { - case 'deadline': - this._timeout = options.deadline; - break; - - case 'response': - this._responseTimeout = options.response; - break; - - case 'upload': - this._uploadTimeout = options.upload; - break; - - default: - console.warn('Unknown timeout option', option); - } - } - } - - return this; - }; - /** - * Set number of retry attempts on error. - * - * Failed requests will be retried 'count' times if timeout or err.code >= 500. - * - * @param {Number} count - * @param {Function} [fn] - * @return {Request} for chaining - * @api public - */ - - - RequestBase.prototype.retry = function (count, fn) { - // Default to 1 if no count passed or true - if (arguments.length === 0 || count === true) count = 1; - if (count <= 0) count = 0; - this._maxRetries = count; - this._retries = 0; - this._retryCallback = fn; - return this; - }; // - // NOTE: we do not include ESOCKETTIMEDOUT because that is from `request` package - // - // - // NOTE: we do not include EADDRINFO because it was removed from libuv in 2014 - // - // - // - // - // TODO: expose these as configurable defaults - // - - - var ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']); - var STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]); // TODO: we would need to make this easily configurable before adding it in (e.g. some might want to add POST) - // const METHODS = new Set(['GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE']); - - /** - * Determine if a request should be retried. - * (Inspired by https://github.com/sindresorhus/got#retry) - * - * @param {Error} err an error - * @param {Response} [res] response - * @returns {Boolean} if segment should be retried - */ - - RequestBase.prototype._shouldRetry = function (err, res) { - if (!this._maxRetries || this._retries++ >= this._maxRetries) { - return false; - } - - if (this._retryCallback) { - try { - var override = this._retryCallback(err, res); - - if (override === true) return true; - if (override === false) return false; // undefined falls back to defaults - } catch (err_) { - console.error(err_); - } - } // TODO: we would need to make this easily configurable before adding it in (e.g. some might want to add POST) - - /* - if ( - this.req && - this.req.method && - !METHODS.has(this.req.method.toUpperCase()) - ) - return false; - */ - - - if (res && res.status && STATUS_CODES.has(res.status)) return true; - - if (err) { - if (err.code && ERROR_CODES.has(err.code)) return true; // Superagent timeout - - if (err.timeout && err.code === 'ECONNABORTED') return true; - if (err.crossDomain) return true; - } - - return false; - }; - /** - * Retry request - * - * @return {Request} for chaining - * @api private - */ - - - RequestBase.prototype._retry = function () { - this.clearTimeout(); // node - - if (this.req) { - this.req = null; - this.req = this.request(); - } - - this._aborted = false; - this.timedout = false; - this.timedoutError = null; - return this._end(); - }; - /** - * Promise support - * - * @param {Function} resolve - * @param {Function} [reject] - * @return {Request} - */ - - - RequestBase.prototype.then = function (resolve, reject) { - var _this = this; - - if (!this._fullfilledPromise) { - var self = this; - - if (this._endCalled) { - console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises'); - } - - this._fullfilledPromise = new Promise(function (resolve, reject) { - self.on('abort', function () { - if (_this._maxRetries && _this._maxRetries > _this._retries) { - return; - } - - if (_this.timedout && _this.timedoutError) { - reject(_this.timedoutError); - return; - } - - var err = new Error('Aborted'); - err.code = 'ABORTED'; - err.status = _this.status; - err.method = _this.method; - err.url = _this.url; - reject(err); - }); - self.end(function (err, res) { - if (err) reject(err);else resolve(res); - }); - }); - } - - return this._fullfilledPromise.then(resolve, reject); - }; - - RequestBase.prototype.catch = function (cb) { - return this.then(undefined, cb); - }; - /** - * Allow for extension - */ - - - RequestBase.prototype.use = function (fn) { - fn(this); - return this; - }; - - RequestBase.prototype.ok = function (cb) { - if (typeof cb !== 'function') throw new Error('Callback required'); - this._okCallback = cb; - return this; - }; - - RequestBase.prototype._isResponseOK = function (res) { - if (!res) { - return false; - } - - if (this._okCallback) { - return this._okCallback(res); - } - - return res.status >= 200 && res.status < 300; - }; - /** - * Get request header `field`. - * Case-insensitive. - * - * @param {String} field - * @return {String} - * @api public - */ - - - RequestBase.prototype.get = function (field) { - return this._header[field.toLowerCase()]; - }; - /** - * Get case-insensitive header `field` value. - * This is a deprecated internal API. Use `.get(field)` instead. - * - * (getHeader is no longer used internally by the superagent code base) - * - * @param {String} field - * @return {String} - * @api private - * @deprecated - */ - - - RequestBase.prototype.getHeader = RequestBase.prototype.get; - /** - * Set header `field` to `val`, or multiple fields with one object. - * Case-insensitive. - * - * Examples: - * - * req.get('/') - * .set('Accept', 'application/json') - * .set('X-API-Key', 'foobar') - * .end(callback); - * - * req.get('/') - * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) - * .end(callback); - * - * @param {String|Object} field - * @param {String} val - * @return {Request} for chaining - * @api public - */ - - RequestBase.prototype.set = function (field, value) { - if (isObject(field)) { - for (var key in field) { - if (Object.prototype.hasOwnProperty.call(field, key)) this.set(key, field[key]); - } - - return this; - } - - this._header[field.toLowerCase()] = value; - this.header[field] = value; - return this; - }; - /** - * Remove header `field`. - * Case-insensitive. - * - * Example: - * - * req.get('/') - * .unset('User-Agent') - * .end(callback); - * - * @param {String} field field name - */ - - - RequestBase.prototype.unset = function (field) { - delete this._header[field.toLowerCase()]; - delete this.header[field]; - return this; - }; - /** - * Write the field `name` and `val`, or multiple fields with one object - * for "multipart/form-data" request bodies. - * - * ``` js - * request.post('/upload') - * .field('foo', 'bar') - * .end(callback); - * - * request.post('/upload') - * .field({ foo: 'bar', baz: 'qux' }) - * .end(callback); - * ``` - * - * @param {String|Object} name name of field - * @param {String|Blob|File|Buffer|fs.ReadStream} val value of field - * @return {Request} for chaining - * @api public - */ - - - RequestBase.prototype.field = function (name, value) { - // name should be either a string or an object. - if (name === null || undefined === name) { - throw new Error('.field(name, val) name can not be empty'); - } - - if (this._data) { - throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"); - } - - if (isObject(name)) { - for (var key in name) { - if (Object.prototype.hasOwnProperty.call(name, key)) this.field(key, name[key]); - } - - return this; - } - - if (Array.isArray(value)) { - for (var i in value) { - if (Object.prototype.hasOwnProperty.call(value, i)) this.field(name, value[i]); - } - - return this; - } // val should be defined now - - - if (value === null || undefined === value) { - throw new Error('.field(name, val) val can not be empty'); - } - - if (typeof value === 'boolean') { - value = String(value); - } - - this._getFormData().append(name, value); - - return this; - }; - /** - * Abort the request, and clear potential timeout. - * - * @return {Request} request - * @api public - */ - - - RequestBase.prototype.abort = function () { - if (this._aborted) { - return this; - } - - this._aborted = true; - if (this.xhr) this.xhr.abort(); // browser - - if (this.req) this.req.abort(); // node - - this.clearTimeout(); - this.emit('abort'); - return this; - }; - - RequestBase.prototype._auth = function (user, pass, options, base64Encoder) { - switch (options.type) { - case 'basic': - this.set('Authorization', "Basic ".concat(base64Encoder("".concat(user, ":").concat(pass)))); - break; - - case 'auto': - this.username = user; - this.password = pass; - break; - - case 'bearer': - // usage would be .auth(accessToken, { type: 'bearer' }) - this.set('Authorization', "Bearer ".concat(user)); - break; - } - - return this; - }; - /** - * Enable transmission of cookies with x-domain requests. - * - * Note that for this to work the origin must not be - * using "Access-Control-Allow-Origin" with a wildcard, - * and also must set "Access-Control-Allow-Credentials" - * to "true". - * - * @api public - */ - - - RequestBase.prototype.withCredentials = function (on) { - // This is browser-only functionality. Node side is no-op. - if (on === undefined) on = true; - this._withCredentials = on; - return this; - }; - /** - * Set the max redirects to `n`. Does nothing in browser XHR implementation. - * - * @param {Number} n - * @return {Request} for chaining - * @api public - */ - - - RequestBase.prototype.redirects = function (n) { - this._maxRedirects = n; - return this; - }; - /** - * Maximum size of buffered response body, in bytes. Counts uncompressed size. - * Default 200MB. - * - * @param {Number} n number of bytes - * @return {Request} for chaining - */ - - - RequestBase.prototype.maxResponseSize = function (n) { - if (typeof n !== 'number') { - throw new TypeError('Invalid argument'); - } - - this._maxResponseSize = n; - return this; - }; - /** - * Convert to a plain javascript object (not JSON string) of scalar properties. - * Note as this method is designed to return a useful non-this value, - * it cannot be chained. - * - * @return {Object} describing method, url, and data of this request - * @api public - */ - - - RequestBase.prototype.toJSON = function () { - return { - method: this.method, - url: this.url, - data: this._data, - headers: this._header - }; - }; - /** - * Send `data` as the request body, defaulting the `.type()` to "json" when - * an object is given. - * - * Examples: - * - * // manual json - * request.post('/user') - * .type('json') - * .send('{"name":"tj"}') - * .end(callback) - * - * // auto json - * request.post('/user') - * .send({ name: 'tj' }) - * .end(callback) - * - * // manual x-www-form-urlencoded - * request.post('/user') - * .type('form') - * .send('name=tj') - * .end(callback) - * - * // auto x-www-form-urlencoded - * request.post('/user') - * .type('form') - * .send({ name: 'tj' }) - * .end(callback) - * - * // defaults to x-www-form-urlencoded - * request.post('/user') - * .send('name=tobi') - * .send('species=ferret') - * .end(callback) - * - * @param {String|Object} data - * @return {Request} for chaining - * @api public - */ - // eslint-disable-next-line complexity - - - RequestBase.prototype.send = function (data) { - var isObject_ = isObject(data); - var type = this._header['content-type']; - - if (this._formData) { - throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"); - } - - if (isObject_ && !this._data) { - if (Array.isArray(data)) { - this._data = []; - } else if (!this._isHost(data)) { - this._data = {}; - } - } else if (data && this._data && this._isHost(this._data)) { - throw new Error("Can't merge these send calls"); - } // merge - - - if (isObject_ && isObject(this._data)) { - for (var key in data) { - if (Object.prototype.hasOwnProperty.call(data, key)) this._data[key] = data[key]; - } - } else if (typeof data === 'string') { - // default to x-www-form-urlencoded - if (!type) this.type('form'); - type = this._header['content-type']; - if (type) type = type.toLowerCase().trim(); - - if (type === 'application/x-www-form-urlencoded') { - this._data = this._data ? "".concat(this._data, "&").concat(data) : data; - } else { - this._data = (this._data || '') + data; - } - } else { - this._data = data; - } - - if (!isObject_ || this._isHost(data)) { - return this; - } // default to json - - - if (!type) this.type('json'); - return this; - }; - /** - * Sort `querystring` by the sort function - * - * - * Examples: - * - * // default order - * request.get('/user') - * .query('name=Nick') - * .query('search=Manny') - * .sortQuery() - * .end(callback) - * - * // customized sort function - * request.get('/user') - * .query('name=Nick') - * .query('search=Manny') - * .sortQuery(function(a, b){ - * return a.length - b.length; - * }) - * .end(callback) - * - * - * @param {Function} sort - * @return {Request} for chaining - * @api public - */ - - - RequestBase.prototype.sortQuery = function (sort) { - // _sort default to true but otherwise can be a function or boolean - this._sort = typeof sort === 'undefined' ? true : sort; - return this; - }; - /** - * Compose querystring to append to req.url - * - * @api private - */ - - - RequestBase.prototype._finalizeQueryString = function () { - var query = this._query.join('&'); - - if (query) { - this.url += (this.url.includes('?') ? '&' : '?') + query; - } - - this._query.length = 0; // Makes the call idempotent - - if (this._sort) { - var index = this.url.indexOf('?'); - - if (index >= 0) { - var queryArray = this.url.slice(index + 1).split('&'); - - if (typeof this._sort === 'function') { - queryArray.sort(this._sort); - } else { - queryArray.sort(); - } - - this.url = this.url.slice(0, index) + '?' + queryArray.join('&'); - } - } - }; // For backwards compat only - - - RequestBase.prototype._appendQueryString = function () { - console.warn('Unsupported'); - }; - /** - * Invoke callback with timeout error. - * - * @api private - */ - - - RequestBase.prototype._timeoutError = function (reason, timeout, errno) { - if (this._aborted) { - return; - } - - var err = new Error("".concat(reason + timeout, "ms exceeded")); - err.timeout = timeout; - err.code = 'ECONNABORTED'; - err.errno = errno; - this.timedout = true; - this.timedoutError = err; - this.abort(); - this.callback(err); - }; - - RequestBase.prototype._setTimeouts = function () { - var self = this; // deadline - - if (this._timeout && !this._timer) { - this._timer = setTimeout(function () { - self._timeoutError('Timeout of ', self._timeout, 'ETIME'); - }, this._timeout); - } // response timeout - - - if (this._responseTimeout && !this._responseTimeoutTimer) { - this._responseTimeoutTimer = setTimeout(function () { - self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT'); - }, this._responseTimeout); - } - }; - - var utils$1 = {}; - - function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } - - function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); } - - function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - - /** - * Return the mime type for the given `str`. - * - * @param {String} str - * @return {String} - * @api private - */ - utils$1.type = function (str) { - return str.split(/ *; */).shift(); - }; - /** - * Return header field parameters. - * - * @param {String} str - * @return {Object} - * @api private - */ - - - utils$1.params = function (val) { - var obj = {}; - - var _iterator = _createForOfIteratorHelper(val.split(/ *; */)), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var str = _step.value; - var parts = str.split(/ *= */); - var key = parts.shift(); - - var _val = parts.shift(); - - if (key && _val) obj[key] = _val; - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return obj; - }; - /** - * Parse Link header fields. - * - * @param {String} str - * @return {Object} - * @api private - */ - - - utils$1.parseLinks = function (val) { - var obj = {}; - - var _iterator2 = _createForOfIteratorHelper(val.split(/ *, */)), - _step2; - - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var str = _step2.value; - var parts = str.split(/ *; */); - var url = parts[0].slice(1, -1); - var rel = parts[1].split(/ *= */)[1].slice(1, -1); - obj[rel] = url; - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - - return obj; - }; - /** - * Strip content related fields from `header`. - * - * @param {Object} header - * @return {Object} header - * @api private - */ - - - utils$1.cleanHeader = function (header, changesOrigin) { - delete header['content-type']; - delete header['content-length']; - delete header['transfer-encoding']; - delete header.host; // secuirty - - if (changesOrigin) { - delete header.authorization; - delete header.cookie; - } - - return header; - }; - - /** - * Module dependencies. - */ - var utils = utils$1; - /** - * Expose `ResponseBase`. - */ - - - var responseBase = ResponseBase; - /** - * Initialize a new `ResponseBase`. - * - * @api public - */ - - function ResponseBase(obj) { - if (obj) return mixin(obj); - } - /** - * Mixin the prototype properties. - * - * @param {Object} obj - * @return {Object} - * @api private - */ - - - function mixin(obj) { - for (var key in ResponseBase.prototype) { - if (Object.prototype.hasOwnProperty.call(ResponseBase.prototype, key)) obj[key] = ResponseBase.prototype[key]; - } - - return obj; - } - /** - * Get case-insensitive `field` value. - * - * @param {String} field - * @return {String} - * @api public - */ - - - ResponseBase.prototype.get = function (field) { - return this.header[field.toLowerCase()]; - }; - /** - * Set header related properties: - * - * - `.type` the content type without params - * - * A response of "Content-Type: text/plain; charset=utf-8" - * will provide you with a `.type` of "text/plain". - * - * @param {Object} header - * @api private - */ - - - ResponseBase.prototype._setHeaderProperties = function (header) { - // TODO: moar! - // TODO: make this a util - // content-type - var ct = header['content-type'] || ''; - this.type = utils.type(ct); // params - - var params = utils.params(ct); - - for (var key in params) { - if (Object.prototype.hasOwnProperty.call(params, key)) this[key] = params[key]; - } - - this.links = {}; // links - - try { - if (header.link) { - this.links = utils.parseLinks(header.link); - } - } catch (_unused) {// ignore - } - }; - /** - * Set flags such as `.ok` based on `status`. - * - * For example a 2xx response will give you a `.ok` of __true__ - * whereas 5xx will be __false__ and `.error` will be __true__. The - * `.clientError` and `.serverError` are also available to be more - * specific, and `.statusType` is the class of error ranging from 1..5 - * sometimes useful for mapping respond colors etc. - * - * "sugar" properties are also defined for common cases. Currently providing: - * - * - .noContent - * - .badRequest - * - .unauthorized - * - .notAcceptable - * - .notFound - * - * @param {Number} status - * @api private - */ - - - ResponseBase.prototype._setStatusProperties = function (status) { - var type = status / 100 | 0; // status / class - - this.statusCode = status; - this.status = this.statusCode; - this.statusType = type; // basics - - this.info = type === 1; - this.ok = type === 2; - this.redirect = type === 3; - this.clientError = type === 4; - this.serverError = type === 5; - this.error = type === 4 || type === 5 ? this.toError() : false; // sugar - - this.created = status === 201; - this.accepted = status === 202; - this.noContent = status === 204; - this.badRequest = status === 400; - this.unauthorized = status === 401; - this.notAcceptable = status === 406; - this.forbidden = status === 403; - this.notFound = status === 404; - this.unprocessableEntity = status === 422; - }; - - function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } - - function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } - - function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } - - function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } - - function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } - - function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } - - function Agent() { - this._defaults = []; - } - - ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts'].forEach(function (fn) { - // Default setting for all requests from this agent - Agent.prototype[fn] = function () { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - this._defaults.push({ - fn: fn, - args: args - }); - - return this; - }; - }); - - Agent.prototype._setDefaults = function (req) { - this._defaults.forEach(function (def) { - req[def.fn].apply(req, _toConsumableArray(def.args)); - }); - }; - - var agentBase = Agent; - - (function (module, exports) { - - function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - - /** - * Root reference for iframes. - */ - var root; - - if (typeof window !== 'undefined') { - // Browser window - root = window; - } else if (typeof self === 'undefined') { - // Other environments - console.warn('Using browser-only version of superagent in non-browser environment'); - root = void 0; - } else { - // Web Worker - root = self; - } - - var Emitter = componentEmitter.exports; - - var safeStringify = fastSafeStringify; - - var qs = lib; - - var RequestBase = requestBase; - - var isObject = isObject_1; - - var ResponseBase = responseBase; - - var Agent = agentBase; - /** - * Noop. - */ - - - function noop() {} - /** - * Expose `request`. - */ - - - module.exports = function (method, url) { - // callback - if (typeof url === 'function') { - return new exports.Request('GET', method).end(url); - } // url first - - - if (arguments.length === 1) { - return new exports.Request('GET', method); - } - - return new exports.Request(method, url); - }; - - exports = module.exports; - var request = exports; - exports.Request = Request; - /** - * Determine XHR. - */ - - request.getXHR = function () { - if (root.XMLHttpRequest && (!root.location || root.location.protocol !== 'file:' || !root.ActiveXObject)) { - return new XMLHttpRequest(); - } - - try { - return new ActiveXObject('Microsoft.XMLHTTP'); - } catch (_unused) {} - - try { - return new ActiveXObject('Msxml2.XMLHTTP.6.0'); - } catch (_unused2) {} - - try { - return new ActiveXObject('Msxml2.XMLHTTP.3.0'); - } catch (_unused3) {} - - try { - return new ActiveXObject('Msxml2.XMLHTTP'); - } catch (_unused4) {} - - throw new Error('Browser-only version of superagent could not find XHR'); - }; - /** - * Removes leading and trailing whitespace, added to support IE. - * - * @param {String} s - * @return {String} - * @api private - */ - - - var trim = ''.trim ? function (s) { - return s.trim(); - } : function (s) { - return s.replace(/(^\s*|\s*$)/g, ''); - }; - /** - * Serialize the given `obj`. - * - * @param {Object} obj - * @return {String} - * @api private - */ - - function serialize(obj) { - if (!isObject(obj)) return obj; - var pairs = []; - - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) pushEncodedKeyValuePair(pairs, key, obj[key]); - } - - return pairs.join('&'); - } - /** - * Helps 'serialize' with serializing arrays. - * Mutates the pairs array. - * - * @param {Array} pairs - * @param {String} key - * @param {Mixed} val - */ - - - function pushEncodedKeyValuePair(pairs, key, val) { - if (val === undefined) return; - - if (val === null) { - pairs.push(encodeURI(key)); - return; - } - - if (Array.isArray(val)) { - val.forEach(function (v) { - pushEncodedKeyValuePair(pairs, key, v); - }); - } else if (isObject(val)) { - for (var subkey in val) { - if (Object.prototype.hasOwnProperty.call(val, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), val[subkey]); - } - } else { - pairs.push(encodeURI(key) + '=' + encodeURIComponent(val)); - } - } - /** - * Expose serialization method. - */ - - - request.serializeObject = serialize; - /** - * Parse the given x-www-form-urlencoded `str`. - * - * @param {String} str - * @return {Object} - * @api private - */ - - function parseString(str) { - var obj = {}; - var pairs = str.split('&'); - var pair; - var pos; - - for (var i = 0, len = pairs.length; i < len; ++i) { - pair = pairs[i]; - pos = pair.indexOf('='); - - if (pos === -1) { - obj[decodeURIComponent(pair)] = ''; - } else { - obj[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1)); - } - } - - return obj; - } - /** - * Expose parser. - */ - - - request.parseString = parseString; - /** - * Default MIME type map. - * - * superagent.types.xml = 'application/xml'; - * - */ - - request.types = { - html: 'text/html', - json: 'application/json', - xml: 'text/xml', - urlencoded: 'application/x-www-form-urlencoded', - form: 'application/x-www-form-urlencoded', - 'form-data': 'application/x-www-form-urlencoded' - }; - /** - * Default serialization map. - * - * superagent.serialize['application/xml'] = function(obj){ - * return 'generated xml here'; - * }; - * - */ - - request.serialize = { - 'application/x-www-form-urlencoded': qs.stringify, - 'application/json': safeStringify - }; - /** - * Default parsers. - * - * superagent.parse['application/xml'] = function(str){ - * return { object parsed from str }; - * }; - * - */ - - request.parse = { - 'application/x-www-form-urlencoded': parseString, - 'application/json': JSON.parse - }; - /** - * Parse the given header `str` into - * an object containing the mapped fields. - * - * @param {String} str - * @return {Object} - * @api private - */ - - function parseHeader(str) { - var lines = str.split(/\r?\n/); - var fields = {}; - var index; - var line; - var field; - var val; - - for (var i = 0, len = lines.length; i < len; ++i) { - line = lines[i]; - index = line.indexOf(':'); - - if (index === -1) { - // could be empty line, just skip it - continue; - } - - field = line.slice(0, index).toLowerCase(); - val = trim(line.slice(index + 1)); - fields[field] = val; - } - - return fields; - } - /** - * Check if `mime` is json or has +json structured syntax suffix. - * - * @param {String} mime - * @return {Boolean} - * @api private - */ - - - function isJSON(mime) { - // should match /json or +json - // but not /json-seq - return /[/+]json($|[^-\w])/i.test(mime); - } - /** - * Initialize a new `Response` with the given `xhr`. - * - * - set flags (.ok, .error, etc) - * - parse header - * - * Examples: - * - * Aliasing `superagent` as `request` is nice: - * - * request = superagent; - * - * We can use the promise-like API, or pass callbacks: - * - * request.get('/').end(function(res){}); - * request.get('/', function(res){}); - * - * Sending data can be chained: - * - * request - * .post('/user') - * .send({ name: 'tj' }) - * .end(function(res){}); - * - * Or passed to `.send()`: - * - * request - * .post('/user') - * .send({ name: 'tj' }, function(res){}); - * - * Or passed to `.post()`: - * - * request - * .post('/user', { name: 'tj' }) - * .end(function(res){}); - * - * Or further reduced to a single call for simple cases: - * - * request - * .post('/user', { name: 'tj' }, function(res){}); - * - * @param {XMLHTTPRequest} xhr - * @param {Object} options - * @api private - */ - - - function Response(req) { - this.req = req; - this.xhr = this.req.xhr; // responseText is accessible only if responseType is '' or 'text' and on older browsers - - this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null; - this.statusText = this.req.xhr.statusText; - var status = this.xhr.status; // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request - - if (status === 1223) { - status = 204; - } - - this._setStatusProperties(status); - - this.headers = parseHeader(this.xhr.getAllResponseHeaders()); - this.header = this.headers; // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but - // getResponseHeader still works. so we get content-type even if getting - // other headers fails. - - this.header['content-type'] = this.xhr.getResponseHeader('content-type'); - - this._setHeaderProperties(this.header); - - if (this.text === null && req._responseType) { - this.body = this.xhr.response; - } else { - this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response); - } - } // eslint-disable-next-line new-cap - - - ResponseBase(Response.prototype); - /** - * Parse the given body `str`. - * - * Used for auto-parsing of bodies. Parsers - * are defined on the `superagent.parse` object. - * - * @param {String} str - * @return {Mixed} - * @api private - */ - - Response.prototype._parseBody = function (str) { - var parse = request.parse[this.type]; - - if (this.req._parser) { - return this.req._parser(this, str); - } - - if (!parse && isJSON(this.type)) { - parse = request.parse['application/json']; - } - - return parse && str && (str.length > 0 || str instanceof Object) ? parse(str) : null; - }; - /** - * Return an `Error` representative of this response. - * - * @return {Error} - * @api public - */ - - - Response.prototype.toError = function () { - var req = this.req; - var method = req.method; - var url = req.url; - var msg = "cannot ".concat(method, " ").concat(url, " (").concat(this.status, ")"); - var err = new Error(msg); - err.status = this.status; - err.method = method; - err.url = url; - return err; - }; - /** - * Expose `Response`. - */ - - - request.Response = Response; - /** - * Initialize a new `Request` with the given `method` and `url`. - * - * @param {String} method - * @param {String} url - * @api public - */ - - function Request(method, url) { - var self = this; - this._query = this._query || []; - this.method = method; - this.url = url; - this.header = {}; // preserves header name case - - this._header = {}; // coerces header names to lowercase - - this.on('end', function () { - var err = null; - var res = null; - - try { - res = new Response(self); - } catch (err_) { - err = new Error('Parser is unable to parse the response'); - err.parse = true; - err.original = err_; // issue #675: return the raw response if the response parsing fails - - if (self.xhr) { - // ie9 doesn't have 'response' property - err.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response; // issue #876: return the http status code if the response parsing fails - - err.status = self.xhr.status ? self.xhr.status : null; - err.statusCode = err.status; // backwards-compat only - } else { - err.rawResponse = null; - err.status = null; - } - - return self.callback(err); - } - - self.emit('response', res); - var new_err; - - try { - if (!self._isResponseOK(res)) { - new_err = new Error(res.statusText || res.text || 'Unsuccessful HTTP response'); - } - } catch (err_) { - new_err = err_; // ok() callback can throw - } // #1000 don't catch errors from the callback to avoid double calling it - - - if (new_err) { - new_err.original = err; - new_err.response = res; - new_err.status = res.status; - self.callback(new_err, res); - } else { - self.callback(null, res); - } - }); - } - /** - * Mixin `Emitter` and `RequestBase`. - */ - // eslint-disable-next-line new-cap - - - Emitter(Request.prototype); // eslint-disable-next-line new-cap - - RequestBase(Request.prototype); - /** - * Set Content-Type to `type`, mapping values from `request.types`. - * - * Examples: - * - * superagent.types.xml = 'application/xml'; - * - * request.post('/') - * .type('xml') - * .send(xmlstring) - * .end(callback); - * - * request.post('/') - * .type('application/xml') - * .send(xmlstring) - * .end(callback); - * - * @param {String} type - * @return {Request} for chaining - * @api public - */ - - Request.prototype.type = function (type) { - this.set('Content-Type', request.types[type] || type); - return this; - }; - /** - * Set Accept to `type`, mapping values from `request.types`. - * - * Examples: - * - * superagent.types.json = 'application/json'; - * - * request.get('/agent') - * .accept('json') - * .end(callback); - * - * request.get('/agent') - * .accept('application/json') - * .end(callback); - * - * @param {String} accept - * @return {Request} for chaining - * @api public - */ - - - Request.prototype.accept = function (type) { - this.set('Accept', request.types[type] || type); - return this; - }; - /** - * Set Authorization field value with `user` and `pass`. - * - * @param {String} user - * @param {String} [pass] optional in case of using 'bearer' as type - * @param {Object} options with 'type' property 'auto', 'basic' or 'bearer' (default 'basic') - * @return {Request} for chaining - * @api public - */ - - - Request.prototype.auth = function (user, pass, options) { - if (arguments.length === 1) pass = ''; - - if (_typeof(pass) === 'object' && pass !== null) { - // pass is optional and can be replaced with options - options = pass; - pass = ''; - } - - if (!options) { - options = { - type: typeof btoa === 'function' ? 'basic' : 'auto' - }; - } - - var encoder = function encoder(string) { - if (typeof btoa === 'function') { - return btoa(string); - } - - throw new Error('Cannot use basic auth, btoa is not a function'); - }; - - return this._auth(user, pass, options, encoder); - }; - /** - * Add query-string `val`. - * - * Examples: - * - * request.get('/shoes') - * .query('size=10') - * .query({ color: 'blue' }) - * - * @param {Object|String} val - * @return {Request} for chaining - * @api public - */ - - - Request.prototype.query = function (val) { - if (typeof val !== 'string') val = serialize(val); - if (val) this._query.push(val); - return this; - }; - /** - * Queue the given `file` as an attachment to the specified `field`, - * with optional `options` (or filename). - * - * ``` js - * request.post('/upload') - * .attach('content', new Blob(['hey!'], { type: "text/html"})) - * .end(callback); - * ``` - * - * @param {String} field - * @param {Blob|File} file - * @param {String|Object} options - * @return {Request} for chaining - * @api public - */ - - - Request.prototype.attach = function (field, file, options) { - if (file) { - if (this._data) { - throw new Error("superagent can't mix .send() and .attach()"); - } - - this._getFormData().append(field, file, options || file.name); - } - - return this; - }; - - Request.prototype._getFormData = function () { - if (!this._formData) { - this._formData = new root.FormData(); - } - - return this._formData; - }; - /** - * Invoke the callback with `err` and `res` - * and handle arity check. - * - * @param {Error} err - * @param {Response} res - * @api private - */ - - - Request.prototype.callback = function (err, res) { - if (this._shouldRetry(err, res)) { - return this._retry(); - } - - var fn = this._callback; - this.clearTimeout(); - - if (err) { - if (this._maxRetries) err.retries = this._retries - 1; - this.emit('error', err); - } - - fn(err, res); - }; - /** - * Invoke callback with x-domain error. - * - * @api private - */ - - - Request.prototype.crossDomainError = function () { - var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'); - err.crossDomain = true; - err.status = this.status; - err.method = this.method; - err.url = this.url; - this.callback(err); - }; // This only warns, because the request is still likely to work - - - Request.prototype.agent = function () { - console.warn('This is not supported in browser version of superagent'); - return this; - }; - - Request.prototype.ca = Request.prototype.agent; - Request.prototype.buffer = Request.prototype.ca; // This throws, because it can't send/receive data as expected - - Request.prototype.write = function () { - throw new Error('Streaming is not supported in browser version of superagent'); - }; - - Request.prototype.pipe = Request.prototype.write; - /** - * Check if `obj` is a host object, - * we don't want to serialize these :) - * - * @param {Object} obj host object - * @return {Boolean} is a host object - * @api private - */ - - Request.prototype._isHost = function (obj) { - // Native objects stringify to [object File], [object Blob], [object FormData], etc. - return obj && _typeof(obj) === 'object' && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]'; - }; - /** - * Initiate request, invoking callback `fn(res)` - * with an instanceof `Response`. - * - * @param {Function} fn - * @return {Request} for chaining - * @api public - */ - - - Request.prototype.end = function (fn) { - if (this._endCalled) { - console.warn('Warning: .end() was called twice. This is not supported in superagent'); - } - - this._endCalled = true; // store callback - - this._callback = fn || noop; // querystring - - this._finalizeQueryString(); - - this._end(); - }; - - Request.prototype._setUploadTimeout = function () { - var self = this; // upload timeout it's wokrs only if deadline timeout is off - - if (this._uploadTimeout && !this._uploadTimeoutTimer) { - this._uploadTimeoutTimer = setTimeout(function () { - self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT'); - }, this._uploadTimeout); - } - }; // eslint-disable-next-line complexity - - - Request.prototype._end = function () { - if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called')); - var self = this; - this.xhr = request.getXHR(); - var xhr = this.xhr; - var data = this._formData || this._data; - - this._setTimeouts(); // state change - - - xhr.onreadystatechange = function () { - var readyState = xhr.readyState; - - if (readyState >= 2 && self._responseTimeoutTimer) { - clearTimeout(self._responseTimeoutTimer); - } - - if (readyState !== 4) { - return; - } // In IE9, reads to any property (e.g. status) off of an aborted XHR will - // result in the error "Could not complete the operation due to error c00c023f" - - - var status; - - try { - status = xhr.status; - } catch (_unused5) { - status = 0; - } - - if (!status) { - if (self.timedout || self._aborted) return; - return self.crossDomainError(); - } - - self.emit('end'); - }; // progress - - - var handleProgress = function handleProgress(direction, e) { - if (e.total > 0) { - e.percent = e.loaded / e.total * 100; - - if (e.percent === 100) { - clearTimeout(self._uploadTimeoutTimer); - } - } - - e.direction = direction; - self.emit('progress', e); - }; - - if (this.hasListeners('progress')) { - try { - xhr.addEventListener('progress', handleProgress.bind(null, 'download')); - - if (xhr.upload) { - xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload')); - } - } catch (_unused6) {// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. - // Reported here: - // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context - } - } - - if (xhr.upload) { - this._setUploadTimeout(); - } // initiate request - - - try { - if (this.username && this.password) { - xhr.open(this.method, this.url, true, this.username, this.password); - } else { - xhr.open(this.method, this.url, true); - } - } catch (err) { - // see #1149 - return this.callback(err); - } // CORS - - - if (this._withCredentials) xhr.withCredentials = true; // body - - if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) { - // serialize stuff - var contentType = this._header['content-type']; - - var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : '']; - - if (!_serialize && isJSON(contentType)) { - _serialize = request.serialize['application/json']; - } - - if (_serialize) data = _serialize(data); - } // set header fields - - - for (var field in this.header) { - if (this.header[field] === null) continue; - if (Object.prototype.hasOwnProperty.call(this.header, field)) xhr.setRequestHeader(field, this.header[field]); - } - - if (this._responseType) { - xhr.responseType = this._responseType; - } // send stuff - - - this.emit('request', this); // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing) - // We need null here if data is undefined - - xhr.send(typeof data === 'undefined' ? null : data); - }; - - request.agent = function () { - return new Agent(); - }; - - ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE'].forEach(function (method) { - Agent.prototype[method.toLowerCase()] = function (url, fn) { - var req = new request.Request(method, url); - - this._setDefaults(req); - - if (fn) { - req.end(fn); - } - - return req; - }; - }); - Agent.prototype.del = Agent.prototype.delete; - /** - * GET `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} - * @api public - */ - - request.get = function (url, data, fn) { - var req = request('GET', url); - - if (typeof data === 'function') { - fn = data; - data = null; - } - - if (data) req.query(data); - if (fn) req.end(fn); - return req; - }; - /** - * HEAD `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} - * @api public - */ - - - request.head = function (url, data, fn) { - var req = request('HEAD', url); - - if (typeof data === 'function') { - fn = data; - data = null; - } - - if (data) req.query(data); - if (fn) req.end(fn); - return req; - }; - /** - * OPTIONS query to `url` with optional callback `fn(res)`. - * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} - * @api public - */ - - - request.options = function (url, data, fn) { - var req = request('OPTIONS', url); - - if (typeof data === 'function') { - fn = data; - data = null; - } - - if (data) req.send(data); - if (fn) req.end(fn); - return req; - }; - /** - * DELETE `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} [data] - * @param {Function} [fn] - * @return {Request} - * @api public - */ - - - function del(url, data, fn) { - var req = request('DELETE', url); - - if (typeof data === 'function') { - fn = data; - data = null; - } - - if (data) req.send(data); - if (fn) req.end(fn); - return req; - } - - request.del = del; - request.delete = del; - /** - * PATCH `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} [data] - * @param {Function} [fn] - * @return {Request} - * @api public - */ - - request.patch = function (url, data, fn) { - var req = request('PATCH', url); - - if (typeof data === 'function') { - fn = data; - data = null; - } - - if (data) req.send(data); - if (fn) req.end(fn); - return req; + Emitter.prototype.listeners = function(event){ + this._callbacks = this._callbacks || {}; + return this._callbacks['$' + event] || []; }; - /** - * POST `url` with optional `data` and callback `fn(res)`. - * - * @param {String} url - * @param {Mixed} [data] - * @param {Function} [fn] - * @return {Request} - * @api public - */ - - request.post = function (url, data, fn) { - var req = request('POST', url); - - if (typeof data === 'function') { - fn = data; - data = null; - } - - if (data) req.send(data); - if (fn) req.end(fn); - return req; - }; /** - * PUT `url` with optional `data` and callback `fn(res)`. + * Check if this emitter has `event` handlers. * - * @param {String} url - * @param {Mixed|Function} [data] or fn - * @param {Function} [fn] - * @return {Request} + * @param {String} event + * @return {Boolean} * @api public */ - - request.put = function (url, data, fn) { - var req = request('PUT', url); - - if (typeof data === 'function') { - fn = data; - data = null; - } - - if (data) req.send(data); - if (fn) req.end(fn); - return req; - }; - - }(client, client.exports)); - - var superagent = client.exports; - - /* */ - function log(req) { - var _pickLogger = function () { - if (console && console.log) - return console; // eslint-disable-line no-console - if (window && window.console && window.console.log) - return window.console; - return console; - }; - var start = new Date().getTime(); - var timestamp = new Date().toISOString(); - var logger = _pickLogger(); - logger.log('<<<<<'); - logger.log("[".concat(timestamp, "]"), '\n', req.url, '\n', req.qs); - logger.log('-----'); - req.on('response', function (res) { - var now = new Date().getTime(); - var elapsed = now - start; - var timestampDone = new Date().toISOString(); - logger.log('>>>>>>'); - logger.log("[".concat(timestampDone, " / ").concat(elapsed, "]"), '\n', req.url, '\n', req.qs, '\n', res.text); - logger.log('-----'); - }); - } - function xdr(superagentConstruct, endpoint, callback) { - var _this = this; - if (this._config.logVerbosity) { - superagentConstruct = superagentConstruct.use(log); - } - if (this._config.proxy && this._modules.proxy) { - superagentConstruct = this._modules.proxy.call(this, superagentConstruct); - } - if (this._config.keepAlive && this._modules.keepAlive) { - superagentConstruct = this._modules.keepAlive(superagentConstruct); - } - var sc = superagentConstruct; - if (endpoint.abortSignal) { - var unsubscribe_1 = endpoint.abortSignal.subscribe(function () { - sc.abort(); - unsubscribe_1(); - }); - } - if (endpoint.forceBuffered === true) { - if (typeof Blob === 'undefined') { - sc = sc.buffer().responseType('arraybuffer'); - } - else { - sc = sc.responseType('arraybuffer'); - } - } - else if (endpoint.forceBuffered === false) { - sc = sc.buffer(false); - } - sc = sc.timeout(endpoint.timeout); - sc.on('abort', function () { - return callback({ - category: categories.PNUnknownCategory, - error: true, - operation: endpoint.operation, - errorData: new Error('Aborted'), - }, null); - }); - sc.end(function (err, resp) { - var parsedResponse; - var status = {}; - status.error = err !== null; - status.operation = endpoint.operation; - if (resp && resp.status) { - status.statusCode = resp.status; - } - if (err) { - if (err.response && err.response.text && !_this._config.logVerbosity) { - try { - status.errorData = JSON.parse(err.response.text); - } - catch (e) { - status.errorData = err; - } - } - else { - status.errorData = err; - } - status.category = _this._detectErrorCategory(err); - return callback(status, null); - } - if (endpoint.ignoreBody) { - parsedResponse = { - headers: resp.headers, - redirects: resp.redirects, - response: resp, - }; - } - else { - try { - parsedResponse = JSON.parse(resp.text); - } - catch (e) { - status.errorData = resp; - status.error = true; - return callback(status, null); - } - } - if (parsedResponse.error && - parsedResponse.error === 1 && - parsedResponse.status && - parsedResponse.message && - parsedResponse.service) { - status.errorData = parsedResponse; - status.statusCode = parsedResponse.status; - status.error = true; - status.category = _this._detectErrorCategory(status); - return callback(status, null); - } - if (parsedResponse.error && parsedResponse.error.message) { - status.errorData = parsedResponse.error; - } - return callback(status, parsedResponse); - }); - return sc; - } - function postfile(url, fields, fileInput) { - return __awaiter(this, void 0, void 0, function () { - var agent, result; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - agent = superagent.post(url); - fields.forEach(function (_a) { - var key = _a.key, value = _a.value; - agent = agent.field(key, value); - }); - agent.attach('file', fileInput, { contentType: 'application/octet-stream' }); - return [4 /*yield*/, agent]; - case 1: - result = _a.sent(); - return [2 /*return*/, result]; - } - }); - }); - } - function getfile(params, endpoint, callback) { - var superagentConstruct = superagent - .get(this.getStandardOrigin() + endpoint.url) - .set(endpoint.headers) - .query(params); - return xdr.call(this, superagentConstruct, endpoint, callback); - } - function get(params, endpoint, callback) { - var superagentConstruct = superagent - .get(this.getStandardOrigin() + endpoint.url) - .set(endpoint.headers) - .query(params); - return xdr.call(this, superagentConstruct, endpoint, callback); - } - function post(params, body, endpoint, callback) { - var superagentConstruct = superagent - .post(this.getStandardOrigin() + endpoint.url) - .query(params) - .set(endpoint.headers) - .send(body); - return xdr.call(this, superagentConstruct, endpoint, callback); - } - function patch(params, body, endpoint, callback) { - var superagentConstruct = superagent - .patch(this.getStandardOrigin() + endpoint.url) - .query(params) - .set(endpoint.headers) - .send(body); - return xdr.call(this, superagentConstruct, endpoint, callback); - } - function del(params, endpoint, callback) { - var superagentConstruct = superagent - .delete(this.getStandardOrigin() + endpoint.url) - .set(endpoint.headers) - .query(params); - return xdr.call(this, superagentConstruct, endpoint, callback); - } - - /* global crypto */ - function concatArrayBuffer(ab1, ab2) { - var tmp = new Uint8Array(ab1.byteLength + ab2.byteLength); - tmp.set(new Uint8Array(ab1), 0); - tmp.set(new Uint8Array(ab2), ab1.byteLength); - return tmp.buffer; - } - var WebCryptography = /** @class */ (function () { - function WebCryptography() { - } - Object.defineProperty(WebCryptography.prototype, "algo", { - get: function () { - return 'aes-256-cbc'; - }, - enumerable: false, - configurable: true - }); - WebCryptography.prototype.encrypt = function (key, input) { - return __awaiter(this, void 0, void 0, function () { - var cKey; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.getKey(key)]; - case 1: - cKey = _a.sent(); - if (input instanceof ArrayBuffer) { - return [2 /*return*/, this.encryptArrayBuffer(cKey, input)]; - } - if (typeof input === 'string') { - return [2 /*return*/, this.encryptString(cKey, input)]; - } - throw new Error('Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer'); - } - }); - }); - }; - WebCryptography.prototype.decrypt = function (key, input) { - return __awaiter(this, void 0, void 0, function () { - var cKey; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.getKey(key)]; - case 1: - cKey = _a.sent(); - if (input instanceof ArrayBuffer) { - return [2 /*return*/, this.decryptArrayBuffer(cKey, input)]; - } - if (typeof input === 'string') { - return [2 /*return*/, this.decryptString(cKey, input)]; - } - throw new Error('Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer'); - } - }); - }); - }; - WebCryptography.prototype.encryptFile = function (key, file, File) { - return __awaiter(this, void 0, void 0, function () { - var bKey, abPlaindata, abCipherdata; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.getKey(key)]; - case 1: - bKey = _a.sent(); - return [4 /*yield*/, file.toArrayBuffer()]; - case 2: - abPlaindata = _a.sent(); - return [4 /*yield*/, this.encryptArrayBuffer(bKey, abPlaindata)]; - case 3: - abCipherdata = _a.sent(); - return [2 /*return*/, File.create({ - name: file.name, - mimeType: 'application/octet-stream', - data: abCipherdata, - })]; - } - }); - }); - }; - WebCryptography.prototype.decryptFile = function (key, file, File) { - return __awaiter(this, void 0, void 0, function () { - var bKey, abCipherdata, abPlaindata; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, this.getKey(key)]; - case 1: - bKey = _a.sent(); - return [4 /*yield*/, file.toArrayBuffer()]; - case 2: - abCipherdata = _a.sent(); - return [4 /*yield*/, this.decryptArrayBuffer(bKey, abCipherdata)]; - case 3: - abPlaindata = _a.sent(); - return [2 /*return*/, File.create({ - name: file.name, - data: abPlaindata, - })]; - } - }); - }); - }; - WebCryptography.prototype.getKey = function (key) { - return __awaiter(this, void 0, void 0, function () { - var bKey, abHash, abKey; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - bKey = Buffer.from(key); - return [4 /*yield*/, crypto.subtle.digest('SHA-256', bKey.buffer)]; - case 1: - abHash = _a.sent(); - abKey = Buffer.from(Buffer.from(abHash).toString('hex').slice(0, 32), 'utf8').buffer; - return [2 /*return*/, crypto.subtle.importKey('raw', abKey, 'AES-CBC', true, ['encrypt', 'decrypt'])]; - } - }); - }); - }; - WebCryptography.prototype.encryptArrayBuffer = function (key, plaintext) { - return __awaiter(this, void 0, void 0, function () { - var abIv, _a, _b; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - abIv = crypto.getRandomValues(new Uint8Array(16)); - _a = concatArrayBuffer; - _b = [abIv.buffer]; - return [4 /*yield*/, crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, plaintext)]; - case 1: return [2 /*return*/, _a.apply(void 0, _b.concat([_c.sent()]))]; - } - }); - }); - }; - WebCryptography.prototype.decryptArrayBuffer = function (key, ciphertext) { - return __awaiter(this, void 0, void 0, function () { - var abIv; - return __generator(this, function (_a) { - abIv = ciphertext.slice(0, 16); - return [2 /*return*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, ciphertext.slice(16))]; - }); - }); - }; - WebCryptography.prototype.encryptString = function (key, plaintext) { - return __awaiter(this, void 0, void 0, function () { - var abIv, abPlaintext, abPayload, ciphertext; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - abIv = crypto.getRandomValues(new Uint8Array(16)); - abPlaintext = Buffer.from(plaintext).buffer; - return [4 /*yield*/, crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, abPlaintext)]; - case 1: - abPayload = _a.sent(); - ciphertext = concatArrayBuffer(abIv.buffer, abPayload); - return [2 /*return*/, Buffer.from(ciphertext).toString('utf8')]; - } - }); - }); - }; - WebCryptography.prototype.decryptString = function (key, ciphertext) { - return __awaiter(this, void 0, void 0, function () { - var abCiphertext, abIv, abPayload, abPlaintext; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - abCiphertext = Buffer.from(ciphertext); - abIv = abCiphertext.slice(0, 16); - abPayload = abCiphertext.slice(16); - return [4 /*yield*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, abPayload)]; - case 1: - abPlaintext = _a.sent(); - return [2 /*return*/, Buffer.from(abPlaintext).toString('utf8')]; - } - }); - }); - }; - WebCryptography.IV_LENGTH = 16; - return WebCryptography; - }()); - - /* global File, FileReader */ - var _a; - var PubNubFile = (_a = /** @class */ (function () { - function PubNubFile(config) { - if (config instanceof File) { - this.data = config; - this.name = this.data.name; - this.mimeType = this.data.type; - } - else if (config.data) { - var contents = config.data; - this.data = new File([contents], config.name, { type: config.mimeType }); - this.name = config.name; - if (config.mimeType) { - this.mimeType = config.mimeType; - } - } - if (this.data === undefined) { - throw new Error("Couldn't construct a file out of supplied options."); - } - if (this.name === undefined) { - throw new Error("Couldn't guess filename out of the options. Please provide one."); - } - } - PubNubFile.create = function (config) { - return new this(config); - }; - PubNubFile.prototype.toBuffer = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - throw new Error('This feature is only supported in Node.js environments.'); - }); - }); - }; - PubNubFile.prototype.toStream = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - throw new Error('This feature is only supported in Node.js environments.'); - }); - }); - }; - PubNubFile.prototype.toFileUri = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - throw new Error('This feature is only supported in react native environments.'); - }); - }); - }; - PubNubFile.prototype.toBlob = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, this.data]; - }); - }); - }; - PubNubFile.prototype.toArrayBuffer = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2 /*return*/, new Promise(function (resolve, reject) { - var reader = new FileReader(); - reader.addEventListener('load', function () { - if (reader.result instanceof ArrayBuffer) { - return resolve(reader.result); - } - }); - reader.addEventListener('error', function () { - reject(reader.error); - }); - reader.readAsArrayBuffer(_this.data); - })]; - }); - }); - }; - PubNubFile.prototype.toString = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - return [2 /*return*/, new Promise(function (resolve, reject) { - var reader = new FileReader(); - reader.addEventListener('load', function () { - if (typeof reader.result === 'string') { - return resolve(reader.result); - } - }); - reader.addEventListener('error', function () { - reject(reader.error); - }); - reader.readAsBinaryString(_this.data); - })]; - }); - }); - }; - PubNubFile.prototype.toFile = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - return [2 /*return*/, this.data]; - }); - }); - }; - return PubNubFile; - }()), - _a.supportsFile = typeof File !== 'undefined', - _a.supportsBlob = typeof Blob !== 'undefined', - _a.supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', - _a.supportsBuffer = false, - _a.supportsStream = false, - _a.supportsString = true, - _a.supportsEncryptFile = true, - _a.supportsFileUri = false, - _a); - - /* eslint no-bitwise: ["error", { "allow": ["~", "&", ">>"] }] */ - function sendBeacon(url) { - if (navigator && navigator.sendBeacon) { - navigator.sendBeacon(url); - } - else { - return false; - } - } - var default_1 = /** @class */ (function (_super) { - __extends(default_1, _super); - function default_1(setup) { - var _this = this; - // extract config. - var _a = setup.listenToBrowserNetworkEvents, listenToBrowserNetworkEvents = _a === void 0 ? true : _a; - setup.sdkFamily = 'Web'; - setup.networking = new default_1$2({ - del: del, - get: get, - post: post, - patch: patch, - sendBeacon: sendBeacon, - getfile: getfile, - postfile: postfile, - }); - setup.cbor = new default_1$1(function (arrayBuffer) { return stringifyBufferKeys(CborReader.decode(arrayBuffer)); }, decode$1); - setup.PubNubFile = PubNubFile; - setup.cryptography = new WebCryptography(); - _this = _super.call(this, setup) || this; - if (listenToBrowserNetworkEvents) { - // mount network events. - window.addEventListener('offline', function () { - _this.networkDownDetected(); - }); - window.addEventListener('online', function () { - _this.networkUpDetected(); - }); - } - return _this; - } - return default_1; - }(default_1$3)); - - return default_1; - -})); + Emitter.prototype.hasListeners = function(event){ + return !! this.listeners(event).length; + }; + }(componentEmitter)); + + var fastSafeStringify = stringify$2; + stringify$2.default = stringify$2; + stringify$2.stable = deterministicStringify; + stringify$2.stableStringify = deterministicStringify; + + var LIMIT_REPLACE_NODE = '[...]'; + var CIRCULAR_REPLACE_NODE = '[Circular]'; + + var arr = []; + var replacerStack = []; + + function defaultOptions () { + return { + depthLimit: Number.MAX_SAFE_INTEGER, + edgesLimit: Number.MAX_SAFE_INTEGER + } + } + + // Regular stringify + function stringify$2 (obj, replacer, spacer, options) { + if (typeof options === 'undefined') { + options = defaultOptions(); + } + + decirc(obj, '', 0, [], undefined, 0, options); + var res; + try { + if (replacerStack.length === 0) { + res = JSON.stringify(obj, replacer, spacer); + } else { + res = JSON.stringify(obj, replaceGetterValues(replacer), spacer); + } + } catch (_) { + return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]') + } finally { + while (arr.length !== 0) { + var part = arr.pop(); + if (part.length === 4) { + Object.defineProperty(part[0], part[1], part[3]); + } else { + part[0][part[1]] = part[2]; + } + } + } + return res + } + + function setReplace (replace, val, k, parent) { + var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k); + if (propertyDescriptor.get !== undefined) { + if (propertyDescriptor.configurable) { + Object.defineProperty(parent, k, { value: replace }); + arr.push([parent, k, val, propertyDescriptor]); + } else { + replacerStack.push([val, k, replace]); + } + } else { + parent[k] = replace; + arr.push([parent, k, val]); + } + } + + function decirc (val, k, edgeIndex, stack, parent, depth, options) { + depth += 1; + var i; + if (typeof val === 'object' && val !== null) { + for (i = 0; i < stack.length; i++) { + if (stack[i] === val) { + setReplace(CIRCULAR_REPLACE_NODE, val, k, parent); + return + } + } + + if ( + typeof options.depthLimit !== 'undefined' && + depth > options.depthLimit + ) { + setReplace(LIMIT_REPLACE_NODE, val, k, parent); + return + } + + if ( + typeof options.edgesLimit !== 'undefined' && + edgeIndex + 1 > options.edgesLimit + ) { + setReplace(LIMIT_REPLACE_NODE, val, k, parent); + return + } + + stack.push(val); + // Optimize for Arrays. Big arrays could kill the performance otherwise! + if (Array.isArray(val)) { + for (i = 0; i < val.length; i++) { + decirc(val[i], i, i, stack, val, depth, options); + } + } else { + var keys = Object.keys(val); + for (i = 0; i < keys.length; i++) { + var key = keys[i]; + decirc(val[key], key, i, stack, val, depth, options); + } + } + stack.pop(); + } + } + + // Stable-stringify + function compareFunction (a, b) { + if (a < b) { + return -1 + } + if (a > b) { + return 1 + } + return 0 + } + + function deterministicStringify (obj, replacer, spacer, options) { + if (typeof options === 'undefined') { + options = defaultOptions(); + } + + var tmp = deterministicDecirc(obj, '', 0, [], undefined, 0, options) || obj; + var res; + try { + if (replacerStack.length === 0) { + res = JSON.stringify(tmp, replacer, spacer); + } else { + res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer); + } + } catch (_) { + return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]') + } finally { + // Ensure that we restore the object as it was. + while (arr.length !== 0) { + var part = arr.pop(); + if (part.length === 4) { + Object.defineProperty(part[0], part[1], part[3]); + } else { + part[0][part[1]] = part[2]; + } + } + } + return res + } + + function deterministicDecirc (val, k, edgeIndex, stack, parent, depth, options) { + depth += 1; + var i; + if (typeof val === 'object' && val !== null) { + for (i = 0; i < stack.length; i++) { + if (stack[i] === val) { + setReplace(CIRCULAR_REPLACE_NODE, val, k, parent); + return + } + } + try { + if (typeof val.toJSON === 'function') { + return + } + } catch (_) { + return + } + + if ( + typeof options.depthLimit !== 'undefined' && + depth > options.depthLimit + ) { + setReplace(LIMIT_REPLACE_NODE, val, k, parent); + return + } + + if ( + typeof options.edgesLimit !== 'undefined' && + edgeIndex + 1 > options.edgesLimit + ) { + setReplace(LIMIT_REPLACE_NODE, val, k, parent); + return + } + + stack.push(val); + // Optimize for Arrays. Big arrays could kill the performance otherwise! + if (Array.isArray(val)) { + for (i = 0; i < val.length; i++) { + deterministicDecirc(val[i], i, i, stack, val, depth, options); + } + } else { + // Create a temporary object in the required way + var tmp = {}; + var keys = Object.keys(val).sort(compareFunction); + for (i = 0; i < keys.length; i++) { + var key = keys[i]; + deterministicDecirc(val[key], key, i, stack, val, depth, options); + tmp[key] = val[key]; + } + if (typeof parent !== 'undefined') { + arr.push([parent, k, val]); + parent[k] = tmp; + } else { + return tmp + } + } + stack.pop(); + } + } + + // wraps replacer function to handle values we couldn't replace + // and mark them as replaced value + function replaceGetterValues (replacer) { + replacer = + typeof replacer !== 'undefined' + ? replacer + : function (k, v) { + return v + }; + return function (key, val) { + if (replacerStack.length > 0) { + for (var i = 0; i < replacerStack.length; i++) { + var part = replacerStack[i]; + if (part[1] === key && part[0] === val) { + val = part[2]; + replacerStack.splice(i, 1); + break + } + } + } + return replacer.call(this, key, val) + } + } + + var replace = String.prototype.replace; + var percentTwenties = /%20/g; + + var Format = { + RFC1738: 'RFC1738', + RFC3986: 'RFC3986' + }; + + var formats$3 = { + 'default': Format.RFC3986, + formatters: { + RFC1738: function (value) { + return replace.call(value, percentTwenties, '+'); + }, + RFC3986: function (value) { + return String(value); + } + }, + RFC1738: Format.RFC1738, + RFC3986: Format.RFC3986 + }; + + var formats$2 = formats$3; + + var has$2 = Object.prototype.hasOwnProperty; + var isArray$2 = Array.isArray; + + var hexTable = (function () { + var array = []; + for (var i = 0; i < 256; ++i) { + array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); + } + + return array; + }()); + + var compactQueue = function compactQueue(queue) { + while (queue.length > 1) { + var item = queue.pop(); + var obj = item.obj[item.prop]; + + if (isArray$2(obj)) { + var compacted = []; + + for (var j = 0; j < obj.length; ++j) { + if (typeof obj[j] !== 'undefined') { + compacted.push(obj[j]); + } + } + + item.obj[item.prop] = compacted; + } + } + }; + + var arrayToObject = function arrayToObject(source, options) { + var obj = options && options.plainObjects ? Object.create(null) : {}; + for (var i = 0; i < source.length; ++i) { + if (typeof source[i] !== 'undefined') { + obj[i] = source[i]; + } + } + + return obj; + }; + + var merge = function merge(target, source, options) { + /* eslint no-param-reassign: 0 */ + if (!source) { + return target; + } + + if (typeof source !== 'object') { + if (isArray$2(target)) { + target.push(source); + } else if (target && typeof target === 'object') { + if ((options && (options.plainObjects || options.allowPrototypes)) || !has$2.call(Object.prototype, source)) { + target[source] = true; + } + } else { + return [target, source]; + } + + return target; + } + + if (!target || typeof target !== 'object') { + return [target].concat(source); + } + + var mergeTarget = target; + if (isArray$2(target) && !isArray$2(source)) { + mergeTarget = arrayToObject(target, options); + } + + if (isArray$2(target) && isArray$2(source)) { + source.forEach(function (item, i) { + if (has$2.call(target, i)) { + var targetItem = target[i]; + if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { + target[i] = merge(targetItem, item, options); + } else { + target.push(item); + } + } else { + target[i] = item; + } + }); + return target; + } + + return Object.keys(source).reduce(function (acc, key) { + var value = source[key]; + + if (has$2.call(acc, key)) { + acc[key] = merge(acc[key], value, options); + } else { + acc[key] = value; + } + return acc; + }, mergeTarget); + }; + + var assign = function assignSingleSource(target, source) { + return Object.keys(source).reduce(function (acc, key) { + acc[key] = source[key]; + return acc; + }, target); + }; + + var decode = function (str, decoder, charset) { + var strWithoutPlus = str.replace(/\+/g, ' '); + if (charset === 'iso-8859-1') { + // unescape never throws, no try...catch needed: + return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); + } + // utf-8 + try { + return decodeURIComponent(strWithoutPlus); + } catch (e) { + return strWithoutPlus; + } + }; + + var encode = function encode(str, defaultEncoder, charset, kind, format) { + // This code was originally written by Brian White (mscdex) for the io.js core querystring library. + // It has been adapted here for stricter adherence to RFC 3986 + if (str.length === 0) { + return str; + } + + var string = str; + if (typeof str === 'symbol') { + string = Symbol.prototype.toString.call(str); + } else if (typeof str !== 'string') { + string = String(str); + } + + if (charset === 'iso-8859-1') { + return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { + return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; + }); + } + + var out = ''; + for (var i = 0; i < string.length; ++i) { + var c = string.charCodeAt(i); + + if ( + c === 0x2D // - + || c === 0x2E // . + || c === 0x5F // _ + || c === 0x7E // ~ + || (c >= 0x30 && c <= 0x39) // 0-9 + || (c >= 0x41 && c <= 0x5A) // a-z + || (c >= 0x61 && c <= 0x7A) // A-Z + || (format === formats$2.RFC1738 && (c === 0x28 || c === 0x29)) // ( ) + ) { + out += string.charAt(i); + continue; + } + + if (c < 0x80) { + out = out + hexTable[c]; + continue; + } + + if (c < 0x800) { + out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + if (c < 0xD800 || c >= 0xE000) { + out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + i += 1; + c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); + /* eslint operator-linebreak: [2, "before"] */ + out += hexTable[0xF0 | (c >> 18)] + + hexTable[0x80 | ((c >> 12) & 0x3F)] + + hexTable[0x80 | ((c >> 6) & 0x3F)] + + hexTable[0x80 | (c & 0x3F)]; + } + + return out; + }; + + var compact = function compact(value) { + var queue = [{ obj: { o: value }, prop: 'o' }]; + var refs = []; + + for (var i = 0; i < queue.length; ++i) { + var item = queue[i]; + var obj = item.obj[item.prop]; + + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; ++j) { + var key = keys[j]; + var val = obj[key]; + if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { + queue.push({ obj: obj, prop: key }); + refs.push(val); + } + } + } + + compactQueue(queue); + + return value; + }; + + var isRegExp = function isRegExp(obj) { + return Object.prototype.toString.call(obj) === '[object RegExp]'; + }; + + var isBuffer = function isBuffer(obj) { + if (!obj || typeof obj !== 'object') { + return false; + } + + return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); + }; + + var combine = function combine(a, b) { + return [].concat(a, b); + }; + + var maybeMap = function maybeMap(val, fn) { + if (isArray$2(val)) { + var mapped = []; + for (var i = 0; i < val.length; i += 1) { + mapped.push(fn(val[i])); + } + return mapped; + } + return fn(val); + }; + + var utils$4 = { + arrayToObject: arrayToObject, + assign: assign, + combine: combine, + compact: compact, + decode: decode, + encode: encode, + isBuffer: isBuffer, + isRegExp: isRegExp, + maybeMap: maybeMap, + merge: merge + }; + + var utils$3 = utils$4; + var formats$1 = formats$3; + var has$1 = Object.prototype.hasOwnProperty; + + var arrayPrefixGenerators = { + brackets: function brackets(prefix) { + return prefix + '[]'; + }, + comma: 'comma', + indices: function indices(prefix, key) { + return prefix + '[' + key + ']'; + }, + repeat: function repeat(prefix) { + return prefix; + } + }; + + var isArray$1 = Array.isArray; + var split = String.prototype.split; + var push = Array.prototype.push; + var pushToArray = function (arr, valueOrArray) { + push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]); + }; + + var toISO = Date.prototype.toISOString; + + var defaultFormat = formats$1['default']; + var defaults$1 = { + addQueryPrefix: false, + allowDots: false, + charset: 'utf-8', + charsetSentinel: false, + delimiter: '&', + encode: true, + encoder: utils$3.encode, + encodeValuesOnly: false, + format: defaultFormat, + formatter: formats$1.formatters[defaultFormat], + // deprecated + indices: false, + serializeDate: function serializeDate(date) { + return toISO.call(date); + }, + skipNulls: false, + strictNullHandling: false + }; + + var isNonNullishPrimitive = function isNonNullishPrimitive(v) { + return typeof v === 'string' + || typeof v === 'number' + || typeof v === 'boolean' + || typeof v === 'symbol' + || typeof v === 'bigint'; + }; + + var stringify$1 = function stringify( + object, + prefix, + generateArrayPrefix, + strictNullHandling, + skipNulls, + encoder, + filter, + sort, + allowDots, + serializeDate, + format, + formatter, + encodeValuesOnly, + charset + ) { + var obj = object; + if (typeof filter === 'function') { + obj = filter(prefix, obj); + } else if (obj instanceof Date) { + obj = serializeDate(obj); + } else if (generateArrayPrefix === 'comma' && isArray$1(obj)) { + obj = utils$3.maybeMap(obj, function (value) { + if (value instanceof Date) { + return serializeDate(value); + } + return value; + }); + } + + if (obj === null) { + if (strictNullHandling) { + return encoder && !encodeValuesOnly ? encoder(prefix, defaults$1.encoder, charset, 'key', format) : prefix; + } + + obj = ''; + } + + if (isNonNullishPrimitive(obj) || utils$3.isBuffer(obj)) { + if (encoder) { + var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$1.encoder, charset, 'key', format); + if (generateArrayPrefix === 'comma' && encodeValuesOnly) { + var valuesArray = split.call(String(obj), ','); + var valuesJoined = ''; + for (var i = 0; i < valuesArray.length; ++i) { + valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults$1.encoder, charset, 'value', format)); + } + return [formatter(keyValue) + '=' + valuesJoined]; + } + return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$1.encoder, charset, 'value', format))]; + } + return [formatter(prefix) + '=' + formatter(String(obj))]; + } + + var values = []; + + if (typeof obj === 'undefined') { + return values; + } + + var objKeys; + if (generateArrayPrefix === 'comma' && isArray$1(obj)) { + // we need to join elements in + objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }]; + } else if (isArray$1(filter)) { + objKeys = filter; + } else { + var keys = Object.keys(obj); + objKeys = sort ? keys.sort(sort) : keys; + } + + for (var j = 0; j < objKeys.length; ++j) { + var key = objKeys[j]; + var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key]; + + if (skipNulls && value === null) { + continue; + } + + var keyPrefix = isArray$1(obj) + ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix + : prefix + (allowDots ? '.' + key : '[' + key + ']'); + + pushToArray(values, stringify( + value, + keyPrefix, + generateArrayPrefix, + strictNullHandling, + skipNulls, + encoder, + filter, + sort, + allowDots, + serializeDate, + format, + formatter, + encodeValuesOnly, + charset + )); + } + + return values; + }; + + var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { + if (!opts) { + return defaults$1; + } + + if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + + var charset = opts.charset || defaults$1.charset; + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); + } + + var format = formats$1['default']; + if (typeof opts.format !== 'undefined') { + if (!has$1.call(formats$1.formatters, opts.format)) { + throw new TypeError('Unknown format option provided.'); + } + format = opts.format; + } + var formatter = formats$1.formatters[format]; + + var filter = defaults$1.filter; + if (typeof opts.filter === 'function' || isArray$1(opts.filter)) { + filter = opts.filter; + } + + return { + addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$1.addQueryPrefix, + allowDots: typeof opts.allowDots === 'undefined' ? defaults$1.allowDots : !!opts.allowDots, + charset: charset, + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$1.charsetSentinel, + delimiter: typeof opts.delimiter === 'undefined' ? defaults$1.delimiter : opts.delimiter, + encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$1.encode, + encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$1.encoder, + encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults$1.encodeValuesOnly, + filter: filter, + format: format, + formatter: formatter, + serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$1.serializeDate, + skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$1.skipNulls, + sort: typeof opts.sort === 'function' ? opts.sort : null, + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$1.strictNullHandling + }; + }; + + var stringify_1 = function (object, opts) { + var obj = object; + var options = normalizeStringifyOptions(opts); + + var objKeys; + var filter; + + if (typeof options.filter === 'function') { + filter = options.filter; + obj = filter('', obj); + } else if (isArray$1(options.filter)) { + filter = options.filter; + objKeys = filter; + } + + var keys = []; + + if (typeof obj !== 'object' || obj === null) { + return ''; + } + + var arrayFormat; + if (opts && opts.arrayFormat in arrayPrefixGenerators) { + arrayFormat = opts.arrayFormat; + } else if (opts && 'indices' in opts) { + arrayFormat = opts.indices ? 'indices' : 'repeat'; + } else { + arrayFormat = 'indices'; + } + + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; + + if (!objKeys) { + objKeys = Object.keys(obj); + } + + if (options.sort) { + objKeys.sort(options.sort); + } + + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + + if (options.skipNulls && obj[key] === null) { + continue; + } + pushToArray(keys, stringify$1( + obj[key], + key, + generateArrayPrefix, + options.strictNullHandling, + options.skipNulls, + options.encode ? options.encoder : null, + options.filter, + options.sort, + options.allowDots, + options.serializeDate, + options.format, + options.formatter, + options.encodeValuesOnly, + options.charset + )); + } + + var joined = keys.join(options.delimiter); + var prefix = options.addQueryPrefix === true ? '?' : ''; + + if (options.charsetSentinel) { + if (options.charset === 'iso-8859-1') { + // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark + prefix += 'utf8=%26%2310003%3B&'; + } else { + // encodeURIComponent('✓') + prefix += 'utf8=%E2%9C%93&'; + } + } + + return joined.length > 0 ? prefix + joined : ''; + }; + + var utils$2 = utils$4; + + var has = Object.prototype.hasOwnProperty; + var isArray = Array.isArray; + + var defaults = { + allowDots: false, + allowPrototypes: false, + arrayLimit: 20, + charset: 'utf-8', + charsetSentinel: false, + comma: false, + decoder: utils$2.decode, + delimiter: '&', + depth: 5, + ignoreQueryPrefix: false, + interpretNumericEntities: false, + parameterLimit: 1000, + parseArrays: true, + plainObjects: false, + strictNullHandling: false + }; + + var interpretNumericEntities = function (str) { + return str.replace(/&#(\d+);/g, function ($0, numberStr) { + return String.fromCharCode(parseInt(numberStr, 10)); + }); + }; + + var parseArrayValue = function (val, options) { + if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) { + return val.split(','); + } + + return val; + }; + + // This is what browsers will submit when the ✓ character occurs in an + // application/x-www-form-urlencoded body and the encoding of the page containing + // the form is iso-8859-1, or when the submitted form has an accept-charset + // attribute of iso-8859-1. Presumably also with other charsets that do not contain + // the ✓ character, such as us-ascii. + var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓') + + // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded. + var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓') + + var parseValues = function parseQueryStringValues(str, options) { + var obj = {}; + var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; + var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; + var parts = cleanStr.split(options.delimiter, limit); + var skipIndex = -1; // Keep track of where the utf8 sentinel was found + var i; + + var charset = options.charset; + if (options.charsetSentinel) { + for (i = 0; i < parts.length; ++i) { + if (parts[i].indexOf('utf8=') === 0) { + if (parts[i] === charsetSentinel) { + charset = 'utf-8'; + } else if (parts[i] === isoSentinel) { + charset = 'iso-8859-1'; + } + skipIndex = i; + i = parts.length; // The eslint settings do not allow break; + } + } + } + + for (i = 0; i < parts.length; ++i) { + if (i === skipIndex) { + continue; + } + var part = parts[i]; + + var bracketEqualsPos = part.indexOf(']='); + var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; + + var key, val; + if (pos === -1) { + key = options.decoder(part, defaults.decoder, charset, 'key'); + val = options.strictNullHandling ? null : ''; + } else { + key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key'); + val = utils$2.maybeMap( + parseArrayValue(part.slice(pos + 1), options), + function (encodedVal) { + return options.decoder(encodedVal, defaults.decoder, charset, 'value'); + } + ); + } + + if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { + val = interpretNumericEntities(val); + } + + if (part.indexOf('[]=') > -1) { + val = isArray(val) ? [val] : val; + } + + if (has.call(obj, key)) { + obj[key] = utils$2.combine(obj[key], val); + } else { + obj[key] = val; + } + } + + return obj; + }; + + var parseObject = function (chain, val, options, valuesParsed) { + var leaf = valuesParsed ? val : parseArrayValue(val, options); + + for (var i = chain.length - 1; i >= 0; --i) { + var obj; + var root = chain[i]; + + if (root === '[]' && options.parseArrays) { + obj = [].concat(leaf); + } else { + obj = options.plainObjects ? Object.create(null) : {}; + var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; + var index = parseInt(cleanRoot, 10); + if (!options.parseArrays && cleanRoot === '') { + obj = { 0: leaf }; + } else if ( + !isNaN(index) + && root !== cleanRoot + && String(index) === cleanRoot + && index >= 0 + && (options.parseArrays && index <= options.arrayLimit) + ) { + obj = []; + obj[index] = leaf; + } else if (cleanRoot !== '__proto__') { + obj[cleanRoot] = leaf; + } + } + + leaf = obj; + } + + return leaf; + }; + + var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) { + if (!givenKey) { + return; + } + + // Transform dot notation to bracket notation + var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; + + // The regex chunks + + var brackets = /(\[[^[\]]*])/; + var child = /(\[[^[\]]*])/g; + + // Get the parent + + var segment = options.depth > 0 && brackets.exec(key); + var parent = segment ? key.slice(0, segment.index) : key; + + // Stash the parent if it exists + + var keys = []; + if (parent) { + // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties + if (!options.plainObjects && has.call(Object.prototype, parent)) { + if (!options.allowPrototypes) { + return; + } + } + + keys.push(parent); + } + + // Loop through children appending to the array until we hit depth + + var i = 0; + while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) { + i += 1; + if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { + if (!options.allowPrototypes) { + return; + } + } + keys.push(segment[1]); + } + + // If there's a remainder, just add whatever is left + + if (segment) { + keys.push('[' + key.slice(segment.index) + ']'); + } + + return parseObject(keys, val, options, valuesParsed); + }; + + var normalizeParseOptions = function normalizeParseOptions(opts) { + if (!opts) { + return defaults; + } + + if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { + throw new TypeError('Decoder has to be a function.'); + } + + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); + } + var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; + + return { + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, + allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, + arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, + charset: charset, + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, + comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, + decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, + delimiter: typeof opts.delimiter === 'string' || utils$2.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, + // eslint-disable-next-line no-implicit-coercion, no-extra-parens + depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth, + ignoreQueryPrefix: opts.ignoreQueryPrefix === true, + interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, + parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, + parseArrays: opts.parseArrays !== false, + plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling + }; + }; + + var parse$1 = function (str, opts) { + var options = normalizeParseOptions(opts); + + if (str === '' || str === null || typeof str === 'undefined') { + return options.plainObjects ? Object.create(null) : {}; + } + + var tempObj = typeof str === 'string' ? parseValues(str, options) : str; + var obj = options.plainObjects ? Object.create(null) : {}; + + // Iterate over the keys and setup the new object + + var keys = Object.keys(tempObj); + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string'); + obj = utils$2.merge(obj, newObj, options); + } + + return utils$2.compact(obj); + }; + + var stringify = stringify_1; + var parse = parse$1; + var formats = formats$3; + + var lib = { + formats: formats, + parse: parse, + stringify: stringify + }; + + function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); } + + /** + * Check if `obj` is an object. + * + * @param {Object} obj + * @return {Boolean} + * @api private + */ + function isObject$1(obj) { + return obj !== null && _typeof$1(obj) === 'object'; + } + + var isObject_1 = isObject$1; + + function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + + /** + * Module of mixed-in functions shared between node and client code + */ + var isObject = isObject_1; + /** + * Expose `RequestBase`. + */ + + + var requestBase = RequestBase; + /** + * Initialize a new `RequestBase`. + * + * @api public + */ + + function RequestBase(object) { + if (object) return mixin$1(object); + } + /** + * Mixin the prototype properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + + + function mixin$1(object) { + for (var key in RequestBase.prototype) { + if (Object.prototype.hasOwnProperty.call(RequestBase.prototype, key)) object[key] = RequestBase.prototype[key]; + } + + return object; + } + /** + * Clear previous timeout. + * + * @return {Request} for chaining + * @api public + */ + + + RequestBase.prototype.clearTimeout = function () { + clearTimeout(this._timer); + clearTimeout(this._responseTimeoutTimer); + clearTimeout(this._uploadTimeoutTimer); + delete this._timer; + delete this._responseTimeoutTimer; + delete this._uploadTimeoutTimer; + return this; + }; + /** + * Override default response body parser + * + * This function will be called to convert incoming data into request.body + * + * @param {Function} + * @api public + */ + + + RequestBase.prototype.parse = function (fn) { + this._parser = fn; + return this; + }; + /** + * Set format of binary response body. + * In browser valid formats are 'blob' and 'arraybuffer', + * which return Blob and ArrayBuffer, respectively. + * + * In Node all values result in Buffer. + * + * Examples: + * + * req.get('/') + * .responseType('blob') + * .end(callback); + * + * @param {String} val + * @return {Request} for chaining + * @api public + */ + + + RequestBase.prototype.responseType = function (value) { + this._responseType = value; + return this; + }; + /** + * Override default request body serializer + * + * This function will be called to convert data set via .send or .attach into payload to send + * + * @param {Function} + * @api public + */ + + + RequestBase.prototype.serialize = function (fn) { + this._serializer = fn; + return this; + }; + /** + * Set timeouts. + * + * - response timeout is time between sending request and receiving the first byte of the response. Includes DNS and connection time. + * - deadline is the time from start of the request to receiving response body in full. If the deadline is too short large files may not load at all on slow connections. + * - upload is the time since last bit of data was sent or received. This timeout works only if deadline timeout is off + * + * Value of 0 or false means no timeout. + * + * @param {Number|Object} ms or {response, deadline} + * @return {Request} for chaining + * @api public + */ + + + RequestBase.prototype.timeout = function (options) { + if (!options || _typeof(options) !== 'object') { + this._timeout = options; + this._responseTimeout = 0; + this._uploadTimeout = 0; + return this; + } + + for (var option in options) { + if (Object.prototype.hasOwnProperty.call(options, option)) { + switch (option) { + case 'deadline': + this._timeout = options.deadline; + break; + + case 'response': + this._responseTimeout = options.response; + break; + + case 'upload': + this._uploadTimeout = options.upload; + break; + + default: + console.warn('Unknown timeout option', option); + } + } + } + + return this; + }; + /** + * Set number of retry attempts on error. + * + * Failed requests will be retried 'count' times if timeout or err.code >= 500. + * + * @param {Number} count + * @param {Function} [fn] + * @return {Request} for chaining + * @api public + */ + + + RequestBase.prototype.retry = function (count, fn) { + // Default to 1 if no count passed or true + if (arguments.length === 0 || count === true) count = 1; + if (count <= 0) count = 0; + this._maxRetries = count; + this._retries = 0; + this._retryCallback = fn; + return this; + }; // + // NOTE: we do not include ESOCKETTIMEDOUT because that is from `request` package + // + // + // NOTE: we do not include EADDRINFO because it was removed from libuv in 2014 + // + // + // + // + // TODO: expose these as configurable defaults + // + + + var ERROR_CODES = new Set(['ETIMEDOUT', 'ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE', 'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN']); + var STATUS_CODES = new Set([408, 413, 429, 500, 502, 503, 504, 521, 522, 524]); // TODO: we would need to make this easily configurable before adding it in (e.g. some might want to add POST) + // const METHODS = new Set(['GET', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE']); + + /** + * Determine if a request should be retried. + * (Inspired by https://github.com/sindresorhus/got#retry) + * + * @param {Error} err an error + * @param {Response} [res] response + * @returns {Boolean} if segment should be retried + */ + + RequestBase.prototype._shouldRetry = function (err, res) { + if (!this._maxRetries || this._retries++ >= this._maxRetries) { + return false; + } + + if (this._retryCallback) { + try { + var override = this._retryCallback(err, res); + + if (override === true) return true; + if (override === false) return false; // undefined falls back to defaults + } catch (err_) { + console.error(err_); + } + } // TODO: we would need to make this easily configurable before adding it in (e.g. some might want to add POST) + + /* + if ( + this.req && + this.req.method && + !METHODS.has(this.req.method.toUpperCase()) + ) + return false; + */ + + + if (res && res.status && STATUS_CODES.has(res.status)) return true; + + if (err) { + if (err.code && ERROR_CODES.has(err.code)) return true; // Superagent timeout + + if (err.timeout && err.code === 'ECONNABORTED') return true; + if (err.crossDomain) return true; + } + + return false; + }; + /** + * Retry request + * + * @return {Request} for chaining + * @api private + */ + + + RequestBase.prototype._retry = function () { + this.clearTimeout(); // node + + if (this.req) { + this.req = null; + this.req = this.request(); + } + + this._aborted = false; + this.timedout = false; + this.timedoutError = null; + return this._end(); + }; + /** + * Promise support + * + * @param {Function} resolve + * @param {Function} [reject] + * @return {Request} + */ + + + RequestBase.prototype.then = function (resolve, reject) { + var _this = this; + + if (!this._fullfilledPromise) { + var self = this; + + if (this._endCalled) { + console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises'); + } + + this._fullfilledPromise = new Promise(function (resolve, reject) { + self.on('abort', function () { + if (_this._maxRetries && _this._maxRetries > _this._retries) { + return; + } + + if (_this.timedout && _this.timedoutError) { + reject(_this.timedoutError); + return; + } + + var err = new Error('Aborted'); + err.code = 'ABORTED'; + err.status = _this.status; + err.method = _this.method; + err.url = _this.url; + reject(err); + }); + self.end(function (err, res) { + if (err) reject(err);else resolve(res); + }); + }); + } + + return this._fullfilledPromise.then(resolve, reject); + }; + + RequestBase.prototype.catch = function (cb) { + return this.then(undefined, cb); + }; + /** + * Allow for extension + */ + + + RequestBase.prototype.use = function (fn) { + fn(this); + return this; + }; + + RequestBase.prototype.ok = function (cb) { + if (typeof cb !== 'function') throw new Error('Callback required'); + this._okCallback = cb; + return this; + }; + + RequestBase.prototype._isResponseOK = function (res) { + if (!res) { + return false; + } + + if (this._okCallback) { + return this._okCallback(res); + } + + return res.status >= 200 && res.status < 300; + }; + /** + * Get request header `field`. + * Case-insensitive. + * + * @param {String} field + * @return {String} + * @api public + */ + + + RequestBase.prototype.get = function (field) { + return this._header[field.toLowerCase()]; + }; + /** + * Get case-insensitive header `field` value. + * This is a deprecated internal API. Use `.get(field)` instead. + * + * (getHeader is no longer used internally by the superagent code base) + * + * @param {String} field + * @return {String} + * @api private + * @deprecated + */ + + + RequestBase.prototype.getHeader = RequestBase.prototype.get; + /** + * Set header `field` to `val`, or multiple fields with one object. + * Case-insensitive. + * + * Examples: + * + * req.get('/') + * .set('Accept', 'application/json') + * .set('X-API-Key', 'foobar') + * .end(callback); + * + * req.get('/') + * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' }) + * .end(callback); + * + * @param {String|Object} field + * @param {String} val + * @return {Request} for chaining + * @api public + */ + + RequestBase.prototype.set = function (field, value) { + if (isObject(field)) { + for (var key in field) { + if (Object.prototype.hasOwnProperty.call(field, key)) this.set(key, field[key]); + } + + return this; + } + + this._header[field.toLowerCase()] = value; + this.header[field] = value; + return this; + }; + /** + * Remove header `field`. + * Case-insensitive. + * + * Example: + * + * req.get('/') + * .unset('User-Agent') + * .end(callback); + * + * @param {String} field field name + */ + + + RequestBase.prototype.unset = function (field) { + delete this._header[field.toLowerCase()]; + delete this.header[field]; + return this; + }; + /** + * Write the field `name` and `val`, or multiple fields with one object + * for "multipart/form-data" request bodies. + * + * ``` js + * request.post('/upload') + * .field('foo', 'bar') + * .end(callback); + * + * request.post('/upload') + * .field({ foo: 'bar', baz: 'qux' }) + * .end(callback); + * ``` + * + * @param {String|Object} name name of field + * @param {String|Blob|File|Buffer|fs.ReadStream} val value of field + * @return {Request} for chaining + * @api public + */ + + + RequestBase.prototype.field = function (name, value) { + // name should be either a string or an object. + if (name === null || undefined === name) { + throw new Error('.field(name, val) name can not be empty'); + } + + if (this._data) { + throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"); + } + + if (isObject(name)) { + for (var key in name) { + if (Object.prototype.hasOwnProperty.call(name, key)) this.field(key, name[key]); + } + + return this; + } + + if (Array.isArray(value)) { + for (var i in value) { + if (Object.prototype.hasOwnProperty.call(value, i)) this.field(name, value[i]); + } + + return this; + } // val should be defined now + + + if (value === null || undefined === value) { + throw new Error('.field(name, val) val can not be empty'); + } + + if (typeof value === 'boolean') { + value = String(value); + } + + this._getFormData().append(name, value); + + return this; + }; + /** + * Abort the request, and clear potential timeout. + * + * @return {Request} request + * @api public + */ + + + RequestBase.prototype.abort = function () { + if (this._aborted) { + return this; + } + + this._aborted = true; + if (this.xhr) this.xhr.abort(); // browser + + if (this.req) this.req.abort(); // node + + this.clearTimeout(); + this.emit('abort'); + return this; + }; + + RequestBase.prototype._auth = function (user, pass, options, base64Encoder) { + switch (options.type) { + case 'basic': + this.set('Authorization', "Basic ".concat(base64Encoder("".concat(user, ":").concat(pass)))); + break; + + case 'auto': + this.username = user; + this.password = pass; + break; + + case 'bearer': + // usage would be .auth(accessToken, { type: 'bearer' }) + this.set('Authorization', "Bearer ".concat(user)); + break; + } + + return this; + }; + /** + * Enable transmission of cookies with x-domain requests. + * + * Note that for this to work the origin must not be + * using "Access-Control-Allow-Origin" with a wildcard, + * and also must set "Access-Control-Allow-Credentials" + * to "true". + * + * @api public + */ + + + RequestBase.prototype.withCredentials = function (on) { + // This is browser-only functionality. Node side is no-op. + if (on === undefined) on = true; + this._withCredentials = on; + return this; + }; + /** + * Set the max redirects to `n`. Does nothing in browser XHR implementation. + * + * @param {Number} n + * @return {Request} for chaining + * @api public + */ + + + RequestBase.prototype.redirects = function (n) { + this._maxRedirects = n; + return this; + }; + /** + * Maximum size of buffered response body, in bytes. Counts uncompressed size. + * Default 200MB. + * + * @param {Number} n number of bytes + * @return {Request} for chaining + */ + + + RequestBase.prototype.maxResponseSize = function (n) { + if (typeof n !== 'number') { + throw new TypeError('Invalid argument'); + } + + this._maxResponseSize = n; + return this; + }; + /** + * Convert to a plain javascript object (not JSON string) of scalar properties. + * Note as this method is designed to return a useful non-this value, + * it cannot be chained. + * + * @return {Object} describing method, url, and data of this request + * @api public + */ + + + RequestBase.prototype.toJSON = function () { + return { + method: this.method, + url: this.url, + data: this._data, + headers: this._header + }; + }; + /** + * Send `data` as the request body, defaulting the `.type()` to "json" when + * an object is given. + * + * Examples: + * + * // manual json + * request.post('/user') + * .type('json') + * .send('{"name":"tj"}') + * .end(callback) + * + * // auto json + * request.post('/user') + * .send({ name: 'tj' }) + * .end(callback) + * + * // manual x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send('name=tj') + * .end(callback) + * + * // auto x-www-form-urlencoded + * request.post('/user') + * .type('form') + * .send({ name: 'tj' }) + * .end(callback) + * + * // defaults to x-www-form-urlencoded + * request.post('/user') + * .send('name=tobi') + * .send('species=ferret') + * .end(callback) + * + * @param {String|Object} data + * @return {Request} for chaining + * @api public + */ + // eslint-disable-next-line complexity + + + RequestBase.prototype.send = function (data) { + var isObject_ = isObject(data); + var type = this._header['content-type']; + + if (this._formData) { + throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"); + } + + if (isObject_ && !this._data) { + if (Array.isArray(data)) { + this._data = []; + } else if (!this._isHost(data)) { + this._data = {}; + } + } else if (data && this._data && this._isHost(this._data)) { + throw new Error("Can't merge these send calls"); + } // merge + + + if (isObject_ && isObject(this._data)) { + for (var key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) this._data[key] = data[key]; + } + } else if (typeof data === 'string') { + // default to x-www-form-urlencoded + if (!type) this.type('form'); + type = this._header['content-type']; + if (type) type = type.toLowerCase().trim(); + + if (type === 'application/x-www-form-urlencoded') { + this._data = this._data ? "".concat(this._data, "&").concat(data) : data; + } else { + this._data = (this._data || '') + data; + } + } else { + this._data = data; + } + + if (!isObject_ || this._isHost(data)) { + return this; + } // default to json + + + if (!type) this.type('json'); + return this; + }; + /** + * Sort `querystring` by the sort function + * + * + * Examples: + * + * // default order + * request.get('/user') + * .query('name=Nick') + * .query('search=Manny') + * .sortQuery() + * .end(callback) + * + * // customized sort function + * request.get('/user') + * .query('name=Nick') + * .query('search=Manny') + * .sortQuery(function(a, b){ + * return a.length - b.length; + * }) + * .end(callback) + * + * + * @param {Function} sort + * @return {Request} for chaining + * @api public + */ + + + RequestBase.prototype.sortQuery = function (sort) { + // _sort default to true but otherwise can be a function or boolean + this._sort = typeof sort === 'undefined' ? true : sort; + return this; + }; + /** + * Compose querystring to append to req.url + * + * @api private + */ + + + RequestBase.prototype._finalizeQueryString = function () { + var query = this._query.join('&'); + + if (query) { + this.url += (this.url.includes('?') ? '&' : '?') + query; + } + + this._query.length = 0; // Makes the call idempotent + + if (this._sort) { + var index = this.url.indexOf('?'); + + if (index >= 0) { + var queryArray = this.url.slice(index + 1).split('&'); + + if (typeof this._sort === 'function') { + queryArray.sort(this._sort); + } else { + queryArray.sort(); + } + + this.url = this.url.slice(0, index) + '?' + queryArray.join('&'); + } + } + }; // For backwards compat only + + + RequestBase.prototype._appendQueryString = function () { + console.warn('Unsupported'); + }; + /** + * Invoke callback with timeout error. + * + * @api private + */ + + + RequestBase.prototype._timeoutError = function (reason, timeout, errno) { + if (this._aborted) { + return; + } + + var err = new Error("".concat(reason + timeout, "ms exceeded")); + err.timeout = timeout; + err.code = 'ECONNABORTED'; + err.errno = errno; + this.timedout = true; + this.timedoutError = err; + this.abort(); + this.callback(err); + }; + + RequestBase.prototype._setTimeouts = function () { + var self = this; // deadline + + if (this._timeout && !this._timer) { + this._timer = setTimeout(function () { + self._timeoutError('Timeout of ', self._timeout, 'ETIME'); + }, this._timeout); + } // response timeout + + + if (this._responseTimeout && !this._responseTimeoutTimer) { + this._responseTimeoutTimer = setTimeout(function () { + self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT'); + }, this._responseTimeout); + } + }; + + var utils$1 = {}; + + function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + + function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); } + + function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + /** + * Return the mime type for the given `str`. + * + * @param {String} str + * @return {String} + * @api private + */ + utils$1.type = function (str) { + return str.split(/ *; */).shift(); + }; + /** + * Return header field parameters. + * + * @param {String} str + * @return {Object} + * @api private + */ + + + utils$1.params = function (val) { + var obj = {}; + + var _iterator = _createForOfIteratorHelper(val.split(/ *; */)), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var str = _step.value; + var parts = str.split(/ *= */); + var key = parts.shift(); + + var _val = parts.shift(); + + if (key && _val) obj[key] = _val; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return obj; + }; + /** + * Parse Link header fields. + * + * @param {String} str + * @return {Object} + * @api private + */ + + + utils$1.parseLinks = function (val) { + var obj = {}; + + var _iterator2 = _createForOfIteratorHelper(val.split(/ *, */)), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var str = _step2.value; + var parts = str.split(/ *; */); + var url = parts[0].slice(1, -1); + var rel = parts[1].split(/ *= */)[1].slice(1, -1); + obj[rel] = url; + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + return obj; + }; + /** + * Strip content related fields from `header`. + * + * @param {Object} header + * @return {Object} header + * @api private + */ + + + utils$1.cleanHeader = function (header, changesOrigin) { + delete header['content-type']; + delete header['content-length']; + delete header['transfer-encoding']; + delete header.host; // secuirty + + if (changesOrigin) { + delete header.authorization; + delete header.cookie; + } + + return header; + }; + + /** + * Module dependencies. + */ + var utils = utils$1; + /** + * Expose `ResponseBase`. + */ + + + var responseBase = ResponseBase; + /** + * Initialize a new `ResponseBase`. + * + * @api public + */ + + function ResponseBase(obj) { + if (obj) return mixin(obj); + } + /** + * Mixin the prototype properties. + * + * @param {Object} obj + * @return {Object} + * @api private + */ + + + function mixin(obj) { + for (var key in ResponseBase.prototype) { + if (Object.prototype.hasOwnProperty.call(ResponseBase.prototype, key)) obj[key] = ResponseBase.prototype[key]; + } + + return obj; + } + /** + * Get case-insensitive `field` value. + * + * @param {String} field + * @return {String} + * @api public + */ + + + ResponseBase.prototype.get = function (field) { + return this.header[field.toLowerCase()]; + }; + /** + * Set header related properties: + * + * - `.type` the content type without params + * + * A response of "Content-Type: text/plain; charset=utf-8" + * will provide you with a `.type` of "text/plain". + * + * @param {Object} header + * @api private + */ + + + ResponseBase.prototype._setHeaderProperties = function (header) { + // TODO: moar! + // TODO: make this a util + // content-type + var ct = header['content-type'] || ''; + this.type = utils.type(ct); // params + + var params = utils.params(ct); + + for (var key in params) { + if (Object.prototype.hasOwnProperty.call(params, key)) this[key] = params[key]; + } + + this.links = {}; // links + + try { + if (header.link) { + this.links = utils.parseLinks(header.link); + } + } catch (_unused) {// ignore + } + }; + /** + * Set flags such as `.ok` based on `status`. + * + * For example a 2xx response will give you a `.ok` of __true__ + * whereas 5xx will be __false__ and `.error` will be __true__. The + * `.clientError` and `.serverError` are also available to be more + * specific, and `.statusType` is the class of error ranging from 1..5 + * sometimes useful for mapping respond colors etc. + * + * "sugar" properties are also defined for common cases. Currently providing: + * + * - .noContent + * - .badRequest + * - .unauthorized + * - .notAcceptable + * - .notFound + * + * @param {Number} status + * @api private + */ + + + ResponseBase.prototype._setStatusProperties = function (status) { + var type = status / 100 | 0; // status / class + + this.statusCode = status; + this.status = this.statusCode; + this.statusType = type; // basics + + this.info = type === 1; + this.ok = type === 2; + this.redirect = type === 3; + this.clientError = type === 4; + this.serverError = type === 5; + this.error = type === 4 || type === 5 ? this.toError() : false; // sugar + + this.created = status === 201; + this.accepted = status === 202; + this.noContent = status === 204; + this.badRequest = status === 400; + this.unauthorized = status === 401; + this.notAcceptable = status === 406; + this.forbidden = status === 403; + this.notFound = status === 404; + this.unprocessableEntity = status === 422; + }; + + function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + + function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + + function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + + function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } + + function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + + function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + function Agent() { + this._defaults = []; + } + + ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts'].forEach(function (fn) { + // Default setting for all requests from this agent + Agent.prototype[fn] = function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + this._defaults.push({ + fn: fn, + args: args + }); + + return this; + }; + }); + + Agent.prototype._setDefaults = function (req) { + this._defaults.forEach(function (def) { + req[def.fn].apply(req, _toConsumableArray(def.args)); + }); + }; + + var agentBase = Agent; + + (function (module, exports) { + + function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + + /** + * Root reference for iframes. + */ + var root; + + if (typeof window !== 'undefined') { + // Browser window + root = window; + } else if (typeof self === 'undefined') { + // Other environments + console.warn('Using browser-only version of superagent in non-browser environment'); + root = void 0; + } else { + // Web Worker + root = self; + } + + var Emitter = componentEmitter.exports; + + var safeStringify = fastSafeStringify; + + var qs = lib; + + var RequestBase = requestBase; + + var isObject = isObject_1; + + var ResponseBase = responseBase; + + var Agent = agentBase; + /** + * Noop. + */ + + + function noop() {} + /** + * Expose `request`. + */ + + + module.exports = function (method, url) { + // callback + if (typeof url === 'function') { + return new exports.Request('GET', method).end(url); + } // url first + + + if (arguments.length === 1) { + return new exports.Request('GET', method); + } + + return new exports.Request(method, url); + }; + + exports = module.exports; + var request = exports; + exports.Request = Request; + /** + * Determine XHR. + */ + + request.getXHR = function () { + if (root.XMLHttpRequest && (!root.location || root.location.protocol !== 'file:' || !root.ActiveXObject)) { + return new XMLHttpRequest(); + } + + try { + return new ActiveXObject('Microsoft.XMLHTTP'); + } catch (_unused) {} + + try { + return new ActiveXObject('Msxml2.XMLHTTP.6.0'); + } catch (_unused2) {} + + try { + return new ActiveXObject('Msxml2.XMLHTTP.3.0'); + } catch (_unused3) {} + + try { + return new ActiveXObject('Msxml2.XMLHTTP'); + } catch (_unused4) {} + + throw new Error('Browser-only version of superagent could not find XHR'); + }; + /** + * Removes leading and trailing whitespace, added to support IE. + * + * @param {String} s + * @return {String} + * @api private + */ + + + var trim = ''.trim ? function (s) { + return s.trim(); + } : function (s) { + return s.replace(/(^\s*|\s*$)/g, ''); + }; + /** + * Serialize the given `obj`. + * + * @param {Object} obj + * @return {String} + * @api private + */ + + function serialize(obj) { + if (!isObject(obj)) return obj; + var pairs = []; + + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) pushEncodedKeyValuePair(pairs, key, obj[key]); + } + + return pairs.join('&'); + } + /** + * Helps 'serialize' with serializing arrays. + * Mutates the pairs array. + * + * @param {Array} pairs + * @param {String} key + * @param {Mixed} val + */ + + + function pushEncodedKeyValuePair(pairs, key, val) { + if (val === undefined) return; + + if (val === null) { + pairs.push(encodeURI(key)); + return; + } + + if (Array.isArray(val)) { + val.forEach(function (v) { + pushEncodedKeyValuePair(pairs, key, v); + }); + } else if (isObject(val)) { + for (var subkey in val) { + if (Object.prototype.hasOwnProperty.call(val, subkey)) pushEncodedKeyValuePair(pairs, "".concat(key, "[").concat(subkey, "]"), val[subkey]); + } + } else { + pairs.push(encodeURI(key) + '=' + encodeURIComponent(val)); + } + } + /** + * Expose serialization method. + */ + + + request.serializeObject = serialize; + /** + * Parse the given x-www-form-urlencoded `str`. + * + * @param {String} str + * @return {Object} + * @api private + */ + + function parseString(str) { + var obj = {}; + var pairs = str.split('&'); + var pair; + var pos; + + for (var i = 0, len = pairs.length; i < len; ++i) { + pair = pairs[i]; + pos = pair.indexOf('='); + + if (pos === -1) { + obj[decodeURIComponent(pair)] = ''; + } else { + obj[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1)); + } + } + + return obj; + } + /** + * Expose parser. + */ + + + request.parseString = parseString; + /** + * Default MIME type map. + * + * superagent.types.xml = 'application/xml'; + * + */ + + request.types = { + html: 'text/html', + json: 'application/json', + xml: 'text/xml', + urlencoded: 'application/x-www-form-urlencoded', + form: 'application/x-www-form-urlencoded', + 'form-data': 'application/x-www-form-urlencoded' + }; + /** + * Default serialization map. + * + * superagent.serialize['application/xml'] = function(obj){ + * return 'generated xml here'; + * }; + * + */ + + request.serialize = { + 'application/x-www-form-urlencoded': qs.stringify, + 'application/json': safeStringify + }; + /** + * Default parsers. + * + * superagent.parse['application/xml'] = function(str){ + * return { object parsed from str }; + * }; + * + */ + + request.parse = { + 'application/x-www-form-urlencoded': parseString, + 'application/json': JSON.parse + }; + /** + * Parse the given header `str` into + * an object containing the mapped fields. + * + * @param {String} str + * @return {Object} + * @api private + */ + + function parseHeader(str) { + var lines = str.split(/\r?\n/); + var fields = {}; + var index; + var line; + var field; + var val; + + for (var i = 0, len = lines.length; i < len; ++i) { + line = lines[i]; + index = line.indexOf(':'); + + if (index === -1) { + // could be empty line, just skip it + continue; + } + + field = line.slice(0, index).toLowerCase(); + val = trim(line.slice(index + 1)); + fields[field] = val; + } + + return fields; + } + /** + * Check if `mime` is json or has +json structured syntax suffix. + * + * @param {String} mime + * @return {Boolean} + * @api private + */ + + + function isJSON(mime) { + // should match /json or +json + // but not /json-seq + return /[/+]json($|[^-\w])/i.test(mime); + } + /** + * Initialize a new `Response` with the given `xhr`. + * + * - set flags (.ok, .error, etc) + * - parse header + * + * Examples: + * + * Aliasing `superagent` as `request` is nice: + * + * request = superagent; + * + * We can use the promise-like API, or pass callbacks: + * + * request.get('/').end(function(res){}); + * request.get('/', function(res){}); + * + * Sending data can be chained: + * + * request + * .post('/user') + * .send({ name: 'tj' }) + * .end(function(res){}); + * + * Or passed to `.send()`: + * + * request + * .post('/user') + * .send({ name: 'tj' }, function(res){}); + * + * Or passed to `.post()`: + * + * request + * .post('/user', { name: 'tj' }) + * .end(function(res){}); + * + * Or further reduced to a single call for simple cases: + * + * request + * .post('/user', { name: 'tj' }, function(res){}); + * + * @param {XMLHTTPRequest} xhr + * @param {Object} options + * @api private + */ + + + function Response(req) { + this.req = req; + this.xhr = this.req.xhr; // responseText is accessible only if responseType is '' or 'text' and on older browsers + + this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null; + this.statusText = this.req.xhr.statusText; + var status = this.xhr.status; // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request + + if (status === 1223) { + status = 204; + } + + this._setStatusProperties(status); + + this.headers = parseHeader(this.xhr.getAllResponseHeaders()); + this.header = this.headers; // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but + // getResponseHeader still works. so we get content-type even if getting + // other headers fails. + + this.header['content-type'] = this.xhr.getResponseHeader('content-type'); + + this._setHeaderProperties(this.header); + + if (this.text === null && req._responseType) { + this.body = this.xhr.response; + } else { + this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response); + } + } // eslint-disable-next-line new-cap + + + ResponseBase(Response.prototype); + /** + * Parse the given body `str`. + * + * Used for auto-parsing of bodies. Parsers + * are defined on the `superagent.parse` object. + * + * @param {String} str + * @return {Mixed} + * @api private + */ + + Response.prototype._parseBody = function (str) { + var parse = request.parse[this.type]; + + if (this.req._parser) { + return this.req._parser(this, str); + } + + if (!parse && isJSON(this.type)) { + parse = request.parse['application/json']; + } + + return parse && str && (str.length > 0 || str instanceof Object) ? parse(str) : null; + }; + /** + * Return an `Error` representative of this response. + * + * @return {Error} + * @api public + */ + + + Response.prototype.toError = function () { + var req = this.req; + var method = req.method; + var url = req.url; + var msg = "cannot ".concat(method, " ").concat(url, " (").concat(this.status, ")"); + var err = new Error(msg); + err.status = this.status; + err.method = method; + err.url = url; + return err; + }; + /** + * Expose `Response`. + */ + + + request.Response = Response; + /** + * Initialize a new `Request` with the given `method` and `url`. + * + * @param {String} method + * @param {String} url + * @api public + */ + + function Request(method, url) { + var self = this; + this._query = this._query || []; + this.method = method; + this.url = url; + this.header = {}; // preserves header name case + + this._header = {}; // coerces header names to lowercase + + this.on('end', function () { + var err = null; + var res = null; + + try { + res = new Response(self); + } catch (err_) { + err = new Error('Parser is unable to parse the response'); + err.parse = true; + err.original = err_; // issue #675: return the raw response if the response parsing fails + + if (self.xhr) { + // ie9 doesn't have 'response' property + err.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response; // issue #876: return the http status code if the response parsing fails + + err.status = self.xhr.status ? self.xhr.status : null; + err.statusCode = err.status; // backwards-compat only + } else { + err.rawResponse = null; + err.status = null; + } + + return self.callback(err); + } + + self.emit('response', res); + var new_err; + + try { + if (!self._isResponseOK(res)) { + new_err = new Error(res.statusText || res.text || 'Unsuccessful HTTP response'); + } + } catch (err_) { + new_err = err_; // ok() callback can throw + } // #1000 don't catch errors from the callback to avoid double calling it + + + if (new_err) { + new_err.original = err; + new_err.response = res; + new_err.status = res.status; + self.callback(new_err, res); + } else { + self.callback(null, res); + } + }); + } + /** + * Mixin `Emitter` and `RequestBase`. + */ + // eslint-disable-next-line new-cap + + + Emitter(Request.prototype); // eslint-disable-next-line new-cap + + RequestBase(Request.prototype); + /** + * Set Content-Type to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.xml = 'application/xml'; + * + * request.post('/') + * .type('xml') + * .send(xmlstring) + * .end(callback); + * + * request.post('/') + * .type('application/xml') + * .send(xmlstring) + * .end(callback); + * + * @param {String} type + * @return {Request} for chaining + * @api public + */ + + Request.prototype.type = function (type) { + this.set('Content-Type', request.types[type] || type); + return this; + }; + /** + * Set Accept to `type`, mapping values from `request.types`. + * + * Examples: + * + * superagent.types.json = 'application/json'; + * + * request.get('/agent') + * .accept('json') + * .end(callback); + * + * request.get('/agent') + * .accept('application/json') + * .end(callback); + * + * @param {String} accept + * @return {Request} for chaining + * @api public + */ + + + Request.prototype.accept = function (type) { + this.set('Accept', request.types[type] || type); + return this; + }; + /** + * Set Authorization field value with `user` and `pass`. + * + * @param {String} user + * @param {String} [pass] optional in case of using 'bearer' as type + * @param {Object} options with 'type' property 'auto', 'basic' or 'bearer' (default 'basic') + * @return {Request} for chaining + * @api public + */ + + + Request.prototype.auth = function (user, pass, options) { + if (arguments.length === 1) pass = ''; + + if (_typeof(pass) === 'object' && pass !== null) { + // pass is optional and can be replaced with options + options = pass; + pass = ''; + } + + if (!options) { + options = { + type: typeof btoa === 'function' ? 'basic' : 'auto' + }; + } + + var encoder = function encoder(string) { + if (typeof btoa === 'function') { + return btoa(string); + } + + throw new Error('Cannot use basic auth, btoa is not a function'); + }; + + return this._auth(user, pass, options, encoder); + }; + /** + * Add query-string `val`. + * + * Examples: + * + * request.get('/shoes') + * .query('size=10') + * .query({ color: 'blue' }) + * + * @param {Object|String} val + * @return {Request} for chaining + * @api public + */ + + + Request.prototype.query = function (val) { + if (typeof val !== 'string') val = serialize(val); + if (val) this._query.push(val); + return this; + }; + /** + * Queue the given `file` as an attachment to the specified `field`, + * with optional `options` (or filename). + * + * ``` js + * request.post('/upload') + * .attach('content', new Blob(['hey!'], { type: "text/html"})) + * .end(callback); + * ``` + * + * @param {String} field + * @param {Blob|File} file + * @param {String|Object} options + * @return {Request} for chaining + * @api public + */ + + + Request.prototype.attach = function (field, file, options) { + if (file) { + if (this._data) { + throw new Error("superagent can't mix .send() and .attach()"); + } + + this._getFormData().append(field, file, options || file.name); + } + + return this; + }; + + Request.prototype._getFormData = function () { + if (!this._formData) { + this._formData = new root.FormData(); + } + + return this._formData; + }; + /** + * Invoke the callback with `err` and `res` + * and handle arity check. + * + * @param {Error} err + * @param {Response} res + * @api private + */ + + + Request.prototype.callback = function (err, res) { + if (this._shouldRetry(err, res)) { + return this._retry(); + } + + var fn = this._callback; + this.clearTimeout(); + + if (err) { + if (this._maxRetries) err.retries = this._retries - 1; + this.emit('error', err); + } + + fn(err, res); + }; + /** + * Invoke callback with x-domain error. + * + * @api private + */ + + + Request.prototype.crossDomainError = function () { + var err = new Error('Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'); + err.crossDomain = true; + err.status = this.status; + err.method = this.method; + err.url = this.url; + this.callback(err); + }; // This only warns, because the request is still likely to work + + + Request.prototype.agent = function () { + console.warn('This is not supported in browser version of superagent'); + return this; + }; + + Request.prototype.ca = Request.prototype.agent; + Request.prototype.buffer = Request.prototype.ca; // This throws, because it can't send/receive data as expected + + Request.prototype.write = function () { + throw new Error('Streaming is not supported in browser version of superagent'); + }; + + Request.prototype.pipe = Request.prototype.write; + /** + * Check if `obj` is a host object, + * we don't want to serialize these :) + * + * @param {Object} obj host object + * @return {Boolean} is a host object + * @api private + */ + + Request.prototype._isHost = function (obj) { + // Native objects stringify to [object File], [object Blob], [object FormData], etc. + return obj && _typeof(obj) === 'object' && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]'; + }; + /** + * Initiate request, invoking callback `fn(res)` + * with an instanceof `Response`. + * + * @param {Function} fn + * @return {Request} for chaining + * @api public + */ + + + Request.prototype.end = function (fn) { + if (this._endCalled) { + console.warn('Warning: .end() was called twice. This is not supported in superagent'); + } + + this._endCalled = true; // store callback + + this._callback = fn || noop; // querystring + + this._finalizeQueryString(); + + this._end(); + }; + + Request.prototype._setUploadTimeout = function () { + var self = this; // upload timeout it's wokrs only if deadline timeout is off + + if (this._uploadTimeout && !this._uploadTimeoutTimer) { + this._uploadTimeoutTimer = setTimeout(function () { + self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT'); + }, this._uploadTimeout); + } + }; // eslint-disable-next-line complexity + + + Request.prototype._end = function () { + if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called')); + var self = this; + this.xhr = request.getXHR(); + var xhr = this.xhr; + var data = this._formData || this._data; + + this._setTimeouts(); // state change + + + xhr.onreadystatechange = function () { + var readyState = xhr.readyState; + + if (readyState >= 2 && self._responseTimeoutTimer) { + clearTimeout(self._responseTimeoutTimer); + } + + if (readyState !== 4) { + return; + } // In IE9, reads to any property (e.g. status) off of an aborted XHR will + // result in the error "Could not complete the operation due to error c00c023f" + + + var status; + + try { + status = xhr.status; + } catch (_unused5) { + status = 0; + } + + if (!status) { + if (self.timedout || self._aborted) return; + return self.crossDomainError(); + } + + self.emit('end'); + }; // progress + + + var handleProgress = function handleProgress(direction, e) { + if (e.total > 0) { + e.percent = e.loaded / e.total * 100; + + if (e.percent === 100) { + clearTimeout(self._uploadTimeoutTimer); + } + } + + e.direction = direction; + self.emit('progress', e); + }; + + if (this.hasListeners('progress')) { + try { + xhr.addEventListener('progress', handleProgress.bind(null, 'download')); + + if (xhr.upload) { + xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload')); + } + } catch (_unused6) {// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist. + // Reported here: + // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context + } + } + + if (xhr.upload) { + this._setUploadTimeout(); + } // initiate request + + + try { + if (this.username && this.password) { + xhr.open(this.method, this.url, true, this.username, this.password); + } else { + xhr.open(this.method, this.url, true); + } + } catch (err) { + // see #1149 + return this.callback(err); + } // CORS + + + if (this._withCredentials) xhr.withCredentials = true; // body + + if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) { + // serialize stuff + var contentType = this._header['content-type']; + + var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : '']; + + if (!_serialize && isJSON(contentType)) { + _serialize = request.serialize['application/json']; + } + + if (_serialize) data = _serialize(data); + } // set header fields + + + for (var field in this.header) { + if (this.header[field] === null) continue; + if (Object.prototype.hasOwnProperty.call(this.header, field)) xhr.setRequestHeader(field, this.header[field]); + } + + if (this._responseType) { + xhr.responseType = this._responseType; + } // send stuff + + + this.emit('request', this); // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing) + // We need null here if data is undefined + + xhr.send(typeof data === 'undefined' ? null : data); + }; + + request.agent = function () { + return new Agent(); + }; + + ['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE'].forEach(function (method) { + Agent.prototype[method.toLowerCase()] = function (url, fn) { + var req = new request.Request(method, url); + + this._setDefaults(req); + + if (fn) { + req.end(fn); + } + + return req; + }; + }); + Agent.prototype.del = Agent.prototype.delete; + /** + * GET `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + + request.get = function (url, data, fn) { + var req = request('GET', url); + + if (typeof data === 'function') { + fn = data; + data = null; + } + + if (data) req.query(data); + if (fn) req.end(fn); + return req; + }; + /** + * HEAD `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + + + request.head = function (url, data, fn) { + var req = request('HEAD', url); + + if (typeof data === 'function') { + fn = data; + data = null; + } + + if (data) req.query(data); + if (fn) req.end(fn); + return req; + }; + /** + * OPTIONS query to `url` with optional callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + + + request.options = function (url, data, fn) { + var req = request('OPTIONS', url); + + if (typeof data === 'function') { + fn = data; + data = null; + } + + if (data) req.send(data); + if (fn) req.end(fn); + return req; + }; + /** + * DELETE `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} [data] + * @param {Function} [fn] + * @return {Request} + * @api public + */ + + + function del(url, data, fn) { + var req = request('DELETE', url); + + if (typeof data === 'function') { + fn = data; + data = null; + } + + if (data) req.send(data); + if (fn) req.end(fn); + return req; + } + + request.del = del; + request.delete = del; + /** + * PATCH `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} [data] + * @param {Function} [fn] + * @return {Request} + * @api public + */ + + request.patch = function (url, data, fn) { + var req = request('PATCH', url); + + if (typeof data === 'function') { + fn = data; + data = null; + } + + if (data) req.send(data); + if (fn) req.end(fn); + return req; + }; + /** + * POST `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed} [data] + * @param {Function} [fn] + * @return {Request} + * @api public + */ + + + request.post = function (url, data, fn) { + var req = request('POST', url); + + if (typeof data === 'function') { + fn = data; + data = null; + } + + if (data) req.send(data); + if (fn) req.end(fn); + return req; + }; + /** + * PUT `url` with optional `data` and callback `fn(res)`. + * + * @param {String} url + * @param {Mixed|Function} [data] or fn + * @param {Function} [fn] + * @return {Request} + * @api public + */ + + + request.put = function (url, data, fn) { + var req = request('PUT', url); + + if (typeof data === 'function') { + fn = data; + data = null; + } + + if (data) req.send(data); + if (fn) req.end(fn); + return req; + }; + + }(client, client.exports)); + + var superagent = client.exports; + + /* */ + function log(req) { + var _pickLogger = function () { + if (console && console.log) + return console; // eslint-disable-line no-console + if (window && window.console && window.console.log) + return window.console; + return console; + }; + var start = new Date().getTime(); + var timestamp = new Date().toISOString(); + var logger = _pickLogger(); + logger.log('<<<<<'); + logger.log("[".concat(timestamp, "]"), '\n', req.url, '\n', req.qs); + logger.log('-----'); + req.on('response', function (res) { + var now = new Date().getTime(); + var elapsed = now - start; + var timestampDone = new Date().toISOString(); + logger.log('>>>>>>'); + logger.log("[".concat(timestampDone, " / ").concat(elapsed, "]"), '\n', req.url, '\n', req.qs, '\n', res.text); + logger.log('-----'); + }); + } + function xdr(superagentConstruct, endpoint, callback) { + var _this = this; + if (this._config.logVerbosity) { + superagentConstruct = superagentConstruct.use(log); + } + if (this._config.proxy && this._modules.proxy) { + superagentConstruct = this._modules.proxy.call(this, superagentConstruct); + } + if (this._config.keepAlive && this._modules.keepAlive) { + superagentConstruct = this._modules.keepAlive(superagentConstruct); + } + var sc = superagentConstruct; + if (endpoint.abortSignal) { + var unsubscribe_1 = endpoint.abortSignal.subscribe(function () { + sc.abort(); + unsubscribe_1(); + }); + } + if (endpoint.forceBuffered === true) { + if (typeof Blob === 'undefined') { + sc = sc.buffer().responseType('arraybuffer'); + } + else { + sc = sc.responseType('arraybuffer'); + } + } + else if (endpoint.forceBuffered === false) { + sc = sc.buffer(false); + } + sc = sc.timeout(endpoint.timeout); + sc.on('abort', function () { + return callback({ + category: categories.PNUnknownCategory, + error: true, + operation: endpoint.operation, + errorData: new Error('Aborted'), + }, null); + }); + sc.end(function (err, resp) { + var parsedResponse; + var status = {}; + status.error = err !== null; + status.operation = endpoint.operation; + if (resp && resp.status) { + status.statusCode = resp.status; + } + if (err) { + if (err.response && err.response.text && !_this._config.logVerbosity) { + try { + status.errorData = JSON.parse(err.response.text); + } + catch (e) { + status.errorData = err; + } + } + else { + status.errorData = err; + } + status.category = _this._detectErrorCategory(err); + return callback(status, null); + } + if (endpoint.ignoreBody) { + parsedResponse = { + headers: resp.headers, + redirects: resp.redirects, + response: resp, + }; + } + else { + try { + parsedResponse = JSON.parse(resp.text); + } + catch (e) { + status.errorData = resp; + status.error = true; + return callback(status, null); + } + } + if (parsedResponse.error && + parsedResponse.error === 1 && + parsedResponse.status && + parsedResponse.message && + parsedResponse.service) { + status.errorData = parsedResponse; + status.statusCode = parsedResponse.status; + status.error = true; + status.category = _this._detectErrorCategory(status); + return callback(status, null); + } + if (parsedResponse.error && parsedResponse.error.message) { + status.errorData = parsedResponse.error; + } + return callback(status, parsedResponse); + }); + return sc; + } + function postfile(url, fields, fileInput) { + return __awaiter(this, void 0, void 0, function () { + var agent, result; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + agent = superagent.post(url); + fields.forEach(function (_a) { + var key = _a.key, value = _a.value; + agent = agent.field(key, value); + }); + agent.attach('file', fileInput, { contentType: 'application/octet-stream' }); + return [4 /*yield*/, agent]; + case 1: + result = _a.sent(); + return [2 /*return*/, result]; + } + }); + }); + } + function getfile(params, endpoint, callback) { + var superagentConstruct = superagent + .get(this.getStandardOrigin() + endpoint.url) + .set(endpoint.headers) + .query(params); + return xdr.call(this, superagentConstruct, endpoint, callback); + } + function get(params, endpoint, callback) { + var superagentConstruct = superagent + .get(this.getStandardOrigin() + endpoint.url) + .set(endpoint.headers) + .query(params); + return xdr.call(this, superagentConstruct, endpoint, callback); + } + function post(params, body, endpoint, callback) { + var superagentConstruct = superagent + .post(this.getStandardOrigin() + endpoint.url) + .query(params) + .set(endpoint.headers) + .send(body); + return xdr.call(this, superagentConstruct, endpoint, callback); + } + function patch(params, body, endpoint, callback) { + var superagentConstruct = superagent + .patch(this.getStandardOrigin() + endpoint.url) + .query(params) + .set(endpoint.headers) + .send(body); + return xdr.call(this, superagentConstruct, endpoint, callback); + } + function del(params, endpoint, callback) { + var superagentConstruct = superagent + .delete(this.getStandardOrigin() + endpoint.url) + .set(endpoint.headers) + .query(params); + return xdr.call(this, superagentConstruct, endpoint, callback); + } + + /* global crypto */ + function concatArrayBuffer(ab1, ab2) { + var tmp = new Uint8Array(ab1.byteLength + ab2.byteLength); + tmp.set(new Uint8Array(ab1), 0); + tmp.set(new Uint8Array(ab2), ab1.byteLength); + return tmp.buffer; + } + var WebCryptography = /** @class */ (function () { + function WebCryptography() { + } + Object.defineProperty(WebCryptography.prototype, "algo", { + get: function () { + return 'aes-256-cbc'; + }, + enumerable: false, + configurable: true + }); + WebCryptography.prototype.encrypt = function (key, input) { + return __awaiter(this, void 0, void 0, function () { + var cKey; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.getKey(key)]; + case 1: + cKey = _a.sent(); + if (input instanceof ArrayBuffer) { + return [2 /*return*/, this.encryptArrayBuffer(cKey, input)]; + } + if (typeof input === 'string') { + return [2 /*return*/, this.encryptString(cKey, input)]; + } + throw new Error('Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer'); + } + }); + }); + }; + WebCryptography.prototype.decrypt = function (key, input) { + return __awaiter(this, void 0, void 0, function () { + var cKey; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.getKey(key)]; + case 1: + cKey = _a.sent(); + if (input instanceof ArrayBuffer) { + return [2 /*return*/, this.decryptArrayBuffer(cKey, input)]; + } + if (typeof input === 'string') { + return [2 /*return*/, this.decryptString(cKey, input)]; + } + throw new Error('Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer'); + } + }); + }); + }; + WebCryptography.prototype.encryptFile = function (key, file, File) { + return __awaiter(this, void 0, void 0, function () { + var bKey, abPlaindata, abCipherdata; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.getKey(key)]; + case 1: + bKey = _a.sent(); + return [4 /*yield*/, file.toArrayBuffer()]; + case 2: + abPlaindata = _a.sent(); + return [4 /*yield*/, this.encryptArrayBuffer(bKey, abPlaindata)]; + case 3: + abCipherdata = _a.sent(); + return [2 /*return*/, File.create({ + name: file.name, + mimeType: 'application/octet-stream', + data: abCipherdata, + })]; + } + }); + }); + }; + WebCryptography.prototype.decryptFile = function (key, file, File) { + return __awaiter(this, void 0, void 0, function () { + var bKey, abCipherdata, abPlaindata; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this.getKey(key)]; + case 1: + bKey = _a.sent(); + return [4 /*yield*/, file.toArrayBuffer()]; + case 2: + abCipherdata = _a.sent(); + return [4 /*yield*/, this.decryptArrayBuffer(bKey, abCipherdata)]; + case 3: + abPlaindata = _a.sent(); + return [2 /*return*/, File.create({ + name: file.name, + data: abPlaindata, + })]; + } + }); + }); + }; + WebCryptography.prototype.getKey = function (key) { + return __awaiter(this, void 0, void 0, function () { + var bKey, abHash, abKey; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + bKey = Buffer.from(key); + return [4 /*yield*/, crypto.subtle.digest('SHA-256', bKey.buffer)]; + case 1: + abHash = _a.sent(); + abKey = Buffer.from(Buffer.from(abHash).toString('hex').slice(0, 32), 'utf8').buffer; + return [2 /*return*/, crypto.subtle.importKey('raw', abKey, 'AES-CBC', true, ['encrypt', 'decrypt'])]; + } + }); + }); + }; + WebCryptography.prototype.encryptArrayBuffer = function (key, plaintext) { + return __awaiter(this, void 0, void 0, function () { + var abIv, _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + abIv = crypto.getRandomValues(new Uint8Array(16)); + _a = concatArrayBuffer; + _b = [abIv.buffer]; + return [4 /*yield*/, crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, plaintext)]; + case 1: return [2 /*return*/, _a.apply(void 0, _b.concat([_c.sent()]))]; + } + }); + }); + }; + WebCryptography.prototype.decryptArrayBuffer = function (key, ciphertext) { + return __awaiter(this, void 0, void 0, function () { + var abIv; + return __generator(this, function (_a) { + abIv = ciphertext.slice(0, 16); + return [2 /*return*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, ciphertext.slice(16))]; + }); + }); + }; + WebCryptography.prototype.encryptString = function (key, plaintext) { + return __awaiter(this, void 0, void 0, function () { + var abIv, abPlaintext, abPayload, ciphertext; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + abIv = crypto.getRandomValues(new Uint8Array(16)); + abPlaintext = Buffer.from(plaintext).buffer; + return [4 /*yield*/, crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, abPlaintext)]; + case 1: + abPayload = _a.sent(); + ciphertext = concatArrayBuffer(abIv.buffer, abPayload); + return [2 /*return*/, Buffer.from(ciphertext).toString('utf8')]; + } + }); + }); + }; + WebCryptography.prototype.decryptString = function (key, ciphertext) { + return __awaiter(this, void 0, void 0, function () { + var abCiphertext, abIv, abPayload, abPlaintext; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + abCiphertext = Buffer.from(ciphertext); + abIv = abCiphertext.slice(0, 16); + abPayload = abCiphertext.slice(16); + return [4 /*yield*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, abPayload)]; + case 1: + abPlaintext = _a.sent(); + return [2 /*return*/, Buffer.from(abPlaintext).toString('utf8')]; + } + }); + }); + }; + WebCryptography.IV_LENGTH = 16; + return WebCryptography; + }()); + + /* global File, FileReader */ + var _a; + var PubNubFile = (_a = /** @class */ (function () { + function PubNubFile(config) { + if (config instanceof File) { + this.data = config; + this.name = this.data.name; + this.mimeType = this.data.type; + } + else if (config.data) { + var contents = config.data; + this.data = new File([contents], config.name, { type: config.mimeType }); + this.name = config.name; + if (config.mimeType) { + this.mimeType = config.mimeType; + } + } + if (this.data === undefined) { + throw new Error("Couldn't construct a file out of supplied options."); + } + if (this.name === undefined) { + throw new Error("Couldn't guess filename out of the options. Please provide one."); + } + } + PubNubFile.create = function (config) { + return new this(config); + }; + PubNubFile.prototype.toBuffer = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + throw new Error('This feature is only supported in Node.js environments.'); + }); + }); + }; + PubNubFile.prototype.toStream = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + throw new Error('This feature is only supported in Node.js environments.'); + }); + }); + }; + PubNubFile.prototype.toFileUri = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + throw new Error('This feature is only supported in react native environments.'); + }); + }); + }; + PubNubFile.prototype.toBlob = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, this.data]; + }); + }); + }; + PubNubFile.prototype.toArrayBuffer = function () { + return __awaiter(this, void 0, void 0, function () { + var _this = this; + return __generator(this, function (_a) { + return [2 /*return*/, new Promise(function (resolve, reject) { + var reader = new FileReader(); + reader.addEventListener('load', function () { + if (reader.result instanceof ArrayBuffer) { + return resolve(reader.result); + } + }); + reader.addEventListener('error', function () { + reject(reader.error); + }); + reader.readAsArrayBuffer(_this.data); + })]; + }); + }); + }; + PubNubFile.prototype.toString = function () { + return __awaiter(this, void 0, void 0, function () { + var _this = this; + return __generator(this, function (_a) { + return [2 /*return*/, new Promise(function (resolve, reject) { + var reader = new FileReader(); + reader.addEventListener('load', function () { + if (typeof reader.result === 'string') { + return resolve(reader.result); + } + }); + reader.addEventListener('error', function () { + reject(reader.error); + }); + reader.readAsBinaryString(_this.data); + })]; + }); + }); + }; + PubNubFile.prototype.toFile = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + return [2 /*return*/, this.data]; + }); + }); + }; + return PubNubFile; + }()), + _a.supportsFile = typeof File !== 'undefined', + _a.supportsBlob = typeof Blob !== 'undefined', + _a.supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', + _a.supportsBuffer = false, + _a.supportsStream = false, + _a.supportsString = true, + _a.supportsEncryptFile = true, + _a.supportsFileUri = false, + _a); + + /* eslint no-bitwise: ["error", { "allow": ["~", "&", ">>"] }] */ + function sendBeacon(url) { + if (navigator && navigator.sendBeacon) { + navigator.sendBeacon(url); + } + else { + return false; + } + } + var default_1 = /** @class */ (function (_super) { + __extends(default_1, _super); + function default_1(setup) { + var _this = this; + // extract config. + var _a = setup.listenToBrowserNetworkEvents, listenToBrowserNetworkEvents = _a === void 0 ? true : _a; + setup.sdkFamily = 'Web'; + setup.networking = new default_1$2({ + del: del, + get: get, + post: post, + patch: patch, + sendBeacon: sendBeacon, + getfile: getfile, + postfile: postfile, + }); + setup.cbor = new default_1$1(function (arrayBuffer) { return stringifyBufferKeys(CborReader.decode(arrayBuffer)); }, decode$1); + setup.PubNubFile = PubNubFile; + setup.cryptography = new WebCryptography(); + _this = _super.call(this, setup) || this; + if (listenToBrowserNetworkEvents) { + // mount network events. + window.addEventListener('offline', function () { + _this.networkDownDetected(); + }); + window.addEventListener('online', function () { + _this.networkUpDetected(); + }); + } + return _this; + } + return default_1; + }(default_1$3)); + + return default_1; + +})); diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 25b5eaa2a..9a82e99f9 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -14,4 +14,4 @@ PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var v=function e(){var i,h,v=l(),b=v>>5,m=31&v;if(7===b)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(b<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(b))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var T;if(h<0)for(T=[];!f();)T.push(e());else for(T=new Array(h),i=0;i=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.3"},e.prototype.setReconnectionConfiguration=function(e,t){this.reconnectionConfiguration=n(n({},config.reconnectionConfiguration),{reconnectionPolicy:e,maximumReconnectionRetries:t})},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],N=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,N,k,a,12,c[1]),k=t(k,T,w,N,l,17,c[2]),N=t(N,k,T,w,p,22,c[3]);w=t(w,N,k,T,h,7,c[4]),T=t(T,w,N,k,f,12,c[5]),k=t(k,T,w,N,d,17,c[6]),N=t(N,k,T,w,g,22,c[7]),w=t(w,N,k,T,y,7,c[8]),T=t(T,w,N,k,v,12,c[9]),k=t(k,T,w,N,b,17,c[10]),N=t(N,k,T,w,m,22,c[11]),w=t(w,N,k,T,_,7,c[12]),T=t(T,w,N,k,O,12,c[13]),k=t(k,T,w,N,P,17,c[14]),w=n(w,N=t(N,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,N,k,d,9,c[17]),k=n(k,T,w,N,m,14,c[18]),N=n(N,k,T,w,u,20,c[19]),w=n(w,N,k,T,f,5,c[20]),T=n(T,w,N,k,b,9,c[21]),k=n(k,T,w,N,S,14,c[22]),N=n(N,k,T,w,h,20,c[23]),w=n(w,N,k,T,v,5,c[24]),T=n(T,w,N,k,P,9,c[25]),k=n(k,T,w,N,p,14,c[26]),N=n(N,k,T,w,y,20,c[27]),w=n(w,N,k,T,O,5,c[28]),T=n(T,w,N,k,l,9,c[29]),k=n(k,T,w,N,g,14,c[30]),w=r(w,N=n(N,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,N,k,y,11,c[33]),k=r(k,T,w,N,m,16,c[34]),N=r(N,k,T,w,P,23,c[35]),w=r(w,N,k,T,a,4,c[36]),T=r(T,w,N,k,h,11,c[37]),k=r(k,T,w,N,g,16,c[38]),N=r(N,k,T,w,b,23,c[39]),w=r(w,N,k,T,O,4,c[40]),T=r(T,w,N,k,u,11,c[41]),k=r(k,T,w,N,p,16,c[42]),N=r(N,k,T,w,d,23,c[43]),w=r(w,N,k,T,v,4,c[44]),T=r(T,w,N,k,_,11,c[45]),k=r(k,T,w,N,S,16,c[46]),w=i(w,N=r(N,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,N,k,g,10,c[49]),k=i(k,T,w,N,P,15,c[50]),N=i(N,k,T,w,f,21,c[51]),w=i(w,N,k,T,_,6,c[52]),T=i(T,w,N,k,p,10,c[53]),k=i(k,T,w,N,b,15,c[54]),N=i(N,k,T,w,a,21,c[55]),w=i(w,N,k,T,y,6,c[56]),T=i(T,w,N,k,S,10,c[57]),k=i(k,T,w,N,d,15,c[58]),N=i(N,k,T,w,O,21,c[59]),w=i(w,N,k,T,h,6,c[60]),T=i(T,w,N,k,m,10,c[61]),k=i(k,T,w,N,l,15,c[62]),N=i(N,k,T,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+N|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function E(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function C(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return C(e).map((function(t){return"".concat(t,"=").concat(E(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:E},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory"},R=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new N({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s;return o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),j={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==j.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==j.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case j.PNPublishOperation:t="pub";break;case j.PNSignalOperation:t="sig";break;case j.PNHistoryOperation:case j.PNFetchMessagesOperation:case j.PNDeleteMessagesOperation:case j.PNMessageCounts:t="hist";break;case j.PNUnsubscribeOperation:case j.PNWhereNowOperation:case j.PNHereNowOperation:case j.PNHeartbeatOperation:case j.PNSetStateOperation:case j.PNGetStateOperation:t="pres";break;case j.PNAddChannelsToGroupOperation:case j.PNRemoveChannelsFromGroupOperation:case j.PNChannelGroupsOperation:case j.PNRemoveGroupOperation:case j.PNChannelsForGroupOperation:t="cg";break;case j.PNPushNotificationEnabledChannelsOperation:case j.PNRemoveAllPushNotificationsOperation:t="push";break;case j.PNCreateUserOperation:case j.PNUpdateUserOperation:case j.PNDeleteUserOperation:case j.PNGetUserOperation:case j.PNGetUsersOperation:case j.PNCreateSpaceOperation:case j.PNUpdateSpaceOperation:case j.PNDeleteSpaceOperation:case j.PNGetSpaceOperation:case j.PNGetSpacesOperation:case j.PNGetMembersOperation:case j.PNUpdateMembersOperation:case j.PNGetMembershipsOperation:case j.PNUpdateMembershipsOperation:t="obj";break;case j.PNAddMessageActionOperation:case j.PNRemoveMessageActionOperation:case j.PNGetMessageActionsOperation:t="msga";break;case j.PNAccessManagerGrant:case j.PNAccessManagerAudit:t="pam";break;case j.PNAccessManagerGrantToken:case j.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function X(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return j.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return j.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return j.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return j.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return j.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return j.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return j.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return j.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,T,k,N,E,C,A,M,R,j,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(E=(N=l).POSTFILE,C=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,E.apply(N,C.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,R=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,R.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(j=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(j,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},be={getOperation:function(){return j.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return j.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return j.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return j.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return j.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return j.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return j.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return j.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return j.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return j.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ce={getOperation:function(){return j.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return j.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return j.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Re=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var je=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return j.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return j.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return j.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return j.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return j.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return j.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return j.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return j.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var Xe=Object.freeze({__proto__:null,getOperation:function(){return j.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),We={getOperation:function(){return j.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return j.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(pt.type,at((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ht.type,at((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Et())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Nt(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(ft.type,at((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(yt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ye("HANDSHAKE_FAILURE");Rt.onEnter((function(e){return pt({category:"PNNetworkIssuesCategory"})})),Rt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),Rt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Rt.on(yt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("STOPPED");jt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(yt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Ct.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ht(e)})),xt.onExit((function(){return ht.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),xt.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Et.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[pt({category:"PNDisconnectedCategory"})])})),xt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])})),xt.on(vt.type,(function(e){return It.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt({category:"PNConnectedCategory"})})),It.onEnter((function(e){return ct(e.channels,e.groups,e.cursor)})),It.onExit((function(){return ct.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[lt(t.payload.events)])})),It.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ft(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return Rt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Dt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return ut(e.channels,e.groups)})),Gt.onExit((function(){return ut.cancel})),Gt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:e.timetoken&&"0"!==e.timetoken?e.timetoken:t.payload.timetoken,region:t.payload.region}})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups,r=e.timetoken;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(dt(this.channels,this.groups,null!=r?r:"0"))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(yt())},e.prototype.disconnect=function(){this.engine.transition(gt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(){}return e.getDelay=function(e,t,n){var r=null!=n?n:5;switch(e.toUpperCase()){case"LINEAR":return t*r+1e3*Math.random();case"EXPONENTIAL":return 1e3*Math.trunc(Math.pow(2,t-1))+1e3*Math.random();default:throw new Error("invalid policy")}},e}(),Bt=function(){function e(e){var t,r=this,i=e.networking,o=e.cbor,c=new g({setup:e});this._config=c;var l=new T({config:c}),p=e.cryptography;i.init(c);var h=new L(c,o);this._tokenManager=h;var f=new U({maximumSamplesCount:6e4});this._telemetryManager=f;var d={config:c,networking:i,crypto:l,cryptography:p,tokenManager:h,telemetryManager:f,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,t){return p.encryptFile(e,t,r.File)},this.decryptFile=function(e,t){return p.decryptFile(e,t,r.File)};var y=X.bind(this,d,Je),v=X.bind(this,d,ie),b=X.bind(this,d,se),m=X.bind(this,d,ue),_=X.bind(this,d,Xe),O=new F;if(this._listenerManager=O,this.iAmHere=X.bind(this,d,se),this.iAmAway=X.bind(this,d,ie),this.setPresenceState=X.bind(this,d,ue),this.handshake=X.bind(this,d,We),this.receiveMessages=X.bind(this,d,$e),!0===c.enableSubscribeBeta){var P=d.config.reconnectionConfiguration.reconnectionPolicy,S=null!==(t=d.config.reconnectionConfiguration.maximumReconnectionRetries)&&void 0!==t?t:0,w=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return Lt.getDelay(P,S)},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return S>=t&&P&&"None"!=P},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;O.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){O.announceStatus(e)}});this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.unsubscribeAll=w.unsubscribeAll.bind(w),this.reconnect=w.reconnect.bind(w),this.disconnect=w.disconnect.bind(w),this.eventEngine=w}else{var k=new R({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:m,subscribeEndpoint:_,crypto:d.crypto,config:d.config,listenerManager:O,getFileUrl:function(e){return ve(d,e)}});this.subscribe=k.adaptSubscribeChange.bind(k),this.unsubscribe=k.adaptUnsubscribeChange.bind(k),this.disconnect=k.disconnect.bind(k),this.reconnect=k.reconnect.bind(k),this.unsubscribeAll=k.unsubscribeAll.bind(k),this.getSubscribedChannels=k.getSubscribedChannels.bind(k),this.getSubscribedChannelGroups=k.getSubscribedChannelGroups.bind(k),this.setState=k.adaptStateChange.bind(k),this.presence=k.adaptPresenceChange.bind(k),this.destroy=function(e){k.unsubscribeAll(e),k.disconnect()}}this.addListener=O.addListener.bind(O),this.removeListener=O.removeListener.bind(O),this.removeAllListeners=O.removeAllListeners.bind(O),this.parseToken=h.parseToken.bind(h),this.setToken=h.setToken.bind(h),this.getToken=h.getToken.bind(h),this.channelGroups={listGroups:X.bind(this,d,Y),listChannels:X.bind(this,d,Z),addChannels:X.bind(this,d,W),removeChannels:X.bind(this,d,$),deleteGroup:X.bind(this,d,Q)},this.push={addChannels:X.bind(this,d,ee),removeChannels:X.bind(this,d,te),deleteDevice:X.bind(this,d,re),listChannels:X.bind(this,d,ne)},this.hereNow=X.bind(this,d,ce),this.whereNow=X.bind(this,d,oe),this.getState=X.bind(this,d,ae),this.grant=X.bind(this,d,je),this.grantToken=X.bind(this,d,De),this.audit=X.bind(this,d,Re),this.revokeToken=X.bind(this,d,Ge),this.publish=X.bind(this,d,Fe),this.fire=function(e,t){return e.replicate=!1,e.storeInHistory=!1,r.publish(e,t)},this.signal=X.bind(this,d,Le),this.history=X.bind(this,d,He),this.deleteMessages=X.bind(this,d,qe),this.messageCounts=X.bind(this,d,ze),this.fetchMessages=X.bind(this,d,Ve),this.addMessageAction=X.bind(this,d,le),this.removeMessageAction=X.bind(this,d,pe),this.getMessageActions=X.bind(this,d,he),this.listFiles=X.bind(this,d,fe);var N=X.bind(this,d,de);this.publishFile=X.bind(this,d,ge),this.sendFile=ye({generateUploadUrl:N,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return ve(d,e)},this.downloadFile=X.bind(this,d,be),this.deleteFile=X.bind(this,d,me),this.objects={getAllUUIDMetadata:X.bind(this,d,_e),getUUIDMetadata:X.bind(this,d,Oe),setUUIDMetadata:X.bind(this,d,Pe),removeUUIDMetadata:X.bind(this,d,Se),getAllChannelMetadata:X.bind(this,d,we),getChannelMetadata:X.bind(this,d,Te),setChannelMetadata:X.bind(this,d,ke),removeChannelMetadata:X.bind(this,d,Ne),getChannelMembers:X.bind(this,d,Ee),setChannelMembers:function(e){for(var t=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function qt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?qt(s):s})),n}var zt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),Vt={exports:{}},Jt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function on(e,t,n,r){void 0===r&&(r=Zt());var i,o=sn(e,"",0,[],void 0,0,r)||e;try{i=0===Yt.length?JSON.stringify(o,t,n):JSON.stringify(o,an(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Qt.length;){var s=Qt.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function sn(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(dn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===hn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=gn[u]:u<2048?s+=gn[192|u>>6]+gn[128|63&u]:u<55296||u>=57344?s+=gn[224|u>>12]+gn[128|u>>6&63]+gn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=gn[240|u>>18]+gn[128|u>>12&63]+gn[128|u>>6&63]+gn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(dn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(Pn(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},In=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&Mn.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},Dn={formats:pn,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||An.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Rn(l)?[l]:l),Mn.call(r,c)?r[c]=An.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Gn(e){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gn(e)}var Kn=function(e){return null!==e&&"object"===Gn(e)};function Fn(e){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fn(e)}var Ln=Kn,Bn=Hn;function Hn(e){if(e)return function(e){for(var t in Hn.prototype)Object.prototype.hasOwnProperty.call(Hn.prototype,t)&&(e[t]=Hn.prototype[t]);return e}(e)}Hn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Hn.prototype.parse=function(e){return this._parser=e,this},Hn.prototype.responseType=function(e){return this._responseType=e,this},Hn.prototype.serialize=function(e){return this._serializer=e,this},Hn.prototype.timeout=function(e){if(!e||"object"!==Fn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Hn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var qn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),zn=new Set([408,413,429,500,502,503,504,521,522,524]);Hn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&zn.has(t.status))return!0;if(e){if(e.code&&qn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Hn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Hn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Hn.prototype.catch=function(e){return this.then(void 0,e)},Hn.prototype.use=function(e){return e(this),this},Hn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Hn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Hn.prototype.get=function(e){return this._header[e.toLowerCase()]},Hn.prototype.getHeader=Hn.prototype.get,Hn.prototype.set=function(e,t){if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Hn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Hn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Hn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Hn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Hn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Hn.prototype.redirects=function(e){return this._maxRedirects=e,this},Hn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Hn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Hn.prototype.send=function(e){var t=Ln(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Ln(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Hn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Hn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Hn.prototype._appendQueryString=function(){console.warn("Unsupported")},Hn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Hn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var Vn={};function Jn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Xn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(Vt,Vt.exports);var nr=Vt.exports;function rr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function ir(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(rr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function or(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=nr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function sr(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ar(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ur(e,t,n,r){var i=nr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function cr(e,t,n,r){var i=nr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function lr(e,t,n){var r=nr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function pr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var hr,fr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=pr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=pr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),dr=(hr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),hr.supportsFile="undefined"!=typeof File,hr.supportsBlob="undefined"!=typeof Blob,hr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,hr.supportsBuffer=!1,hr.supportsStream=!1,hr.supportsString=!0,hr.supportsEncryptFile=!0,hr.supportsFileUri=!1,hr);function gr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var yr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:lr,get:ar,post:ur,patch:cr,sendBeacon:gr,getfile:sr,postfile:or}),t.cbor=new zt((function(e){return qt(p.decode(e))}),y),t.PubNubFile=dr,t.cryptography=new fr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Bt);return yr})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 i(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=i,r.VERSION=t,e.uuid=r,e.isUUID=i}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var f=h.exports,d=function(){return f.uuid?f.uuid():f()},g=function(){function e(e){var t,n,r,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(d()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.setCipherKey(i.cipherKey),this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableSubscribeBeta=null!==(r=i.enableSubscribeBeta)&&void 0!==r&&r,this.reconnectionConfiguration=i.reconnectionConfiguration||{reconnectionPolicy:"None"},"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e){return this.cipherKey=e,this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.3"},e.prototype.setReconnectionConfiguration=function(e,t){this.reconnectionConfiguration=n(n({},config.reconnectionConfiguration),{reconnectionPolicy:e,maximumReconnectionRetries:t})},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],E=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,E,k,a,12,c[1]),k=t(k,T,w,E,l,17,c[2]),E=t(E,k,T,w,p,22,c[3]);w=t(w,E,k,T,h,7,c[4]),T=t(T,w,E,k,f,12,c[5]),k=t(k,T,w,E,d,17,c[6]),E=t(E,k,T,w,g,22,c[7]),w=t(w,E,k,T,y,7,c[8]),T=t(T,w,E,k,v,12,c[9]),k=t(k,T,w,E,b,17,c[10]),E=t(E,k,T,w,m,22,c[11]),w=t(w,E,k,T,_,7,c[12]),T=t(T,w,E,k,O,12,c[13]),k=t(k,T,w,E,P,17,c[14]),w=n(w,E=t(E,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,E,k,d,9,c[17]),k=n(k,T,w,E,m,14,c[18]),E=n(E,k,T,w,u,20,c[19]),w=n(w,E,k,T,f,5,c[20]),T=n(T,w,E,k,b,9,c[21]),k=n(k,T,w,E,S,14,c[22]),E=n(E,k,T,w,h,20,c[23]),w=n(w,E,k,T,v,5,c[24]),T=n(T,w,E,k,P,9,c[25]),k=n(k,T,w,E,p,14,c[26]),E=n(E,k,T,w,y,20,c[27]),w=n(w,E,k,T,O,5,c[28]),T=n(T,w,E,k,l,9,c[29]),k=n(k,T,w,E,g,14,c[30]),w=r(w,E=n(E,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,E,k,y,11,c[33]),k=r(k,T,w,E,m,16,c[34]),E=r(E,k,T,w,P,23,c[35]),w=r(w,E,k,T,a,4,c[36]),T=r(T,w,E,k,h,11,c[37]),k=r(k,T,w,E,g,16,c[38]),E=r(E,k,T,w,b,23,c[39]),w=r(w,E,k,T,O,4,c[40]),T=r(T,w,E,k,u,11,c[41]),k=r(k,T,w,E,p,16,c[42]),E=r(E,k,T,w,d,23,c[43]),w=r(w,E,k,T,v,4,c[44]),T=r(T,w,E,k,_,11,c[45]),k=r(k,T,w,E,S,16,c[46]),w=i(w,E=r(E,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,E,k,g,10,c[49]),k=i(k,T,w,E,P,15,c[50]),E=i(E,k,T,w,f,21,c[51]),w=i(w,E,k,T,_,6,c[52]),T=i(T,w,E,k,p,10,c[53]),k=i(k,T,w,E,b,15,c[54]),E=i(E,k,T,w,a,21,c[55]),w=i(w,E,k,T,y,6,c[56]),T=i(T,w,E,k,S,10,c[57]),k=i(k,T,w,E,d,15,c[58]),E=i(E,k,T,w,O,21,c[59]),w=i(w,E,k,T,h,6,c[60]),T=i(T,w,E,k,m,10,c[61]),k=i(k,T,w,E,l,15,c[62]),E=i(E,k,T,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+E|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function C(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return C(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory"},R=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new E({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s,u=e.withHeartbeat,c=void 0!==u&&u;if(o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),c){var l={};return o.forEach((function(e){return l[e]=r})),a.forEach((function(e){return l[e]=r})),this._heartbeatEndpoint({channels:o,channelGroups:a,state:l},t)}return this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),j={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==j.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==j.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case j.PNPublishOperation:t="pub";break;case j.PNSignalOperation:t="sig";break;case j.PNHistoryOperation:case j.PNFetchMessagesOperation:case j.PNDeleteMessagesOperation:case j.PNMessageCounts:t="hist";break;case j.PNUnsubscribeOperation:case j.PNWhereNowOperation:case j.PNHereNowOperation:case j.PNHeartbeatOperation:case j.PNSetStateOperation:case j.PNGetStateOperation:t="pres";break;case j.PNAddChannelsToGroupOperation:case j.PNRemoveChannelsFromGroupOperation:case j.PNChannelGroupsOperation:case j.PNRemoveGroupOperation:case j.PNChannelsForGroupOperation:t="cg";break;case j.PNPushNotificationEnabledChannelsOperation:case j.PNRemoveAllPushNotificationsOperation:t="push";break;case j.PNCreateUserOperation:case j.PNUpdateUserOperation:case j.PNDeleteUserOperation:case j.PNGetUserOperation:case j.PNGetUsersOperation:case j.PNCreateSpaceOperation:case j.PNUpdateSpaceOperation:case j.PNDeleteSpaceOperation:case j.PNGetSpaceOperation:case j.PNGetSpacesOperation:case j.PNGetMembersOperation:case j.PNUpdateMembersOperation:case j.PNGetMembershipsOperation:case j.PNUpdateMembershipsOperation:t="obj";break;case j.PNAddMessageActionOperation:case j.PNRemoveMessageActionOperation:case j.PNGetMessageActionsOperation:t="msga";break;case j.PNAccessManagerGrant:case j.PNAccessManagerAudit:t="pam";break;case j.PNAccessManagerGrantToken:case j.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function X(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return j.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return j.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return j.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return j.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return j.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return j.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return j.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return j.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,T,k,E,N,C,A,M,R,j,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(N=(E=l).POSTFILE,C=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,N.apply(E,C.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,R=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,R.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(j=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(j,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},be={getOperation:function(){return j.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return j.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return j.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return j.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return j.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return j.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return j.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return j.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return j.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return j.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ce={getOperation:function(){return j.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return j.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return j.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Re=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var je=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return j.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return j.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return j.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return j.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return j.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return j.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return j.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return j.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var Xe=Object.freeze({__proto__:null,getOperation:function(){return j.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),We={getOperation:function(){return j.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return j.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(pt.type,at((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ht.type,at((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Nt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Et(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(ft.type,at((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(yt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ye("HANDSHAKE_FAILURE");Rt.onEnter((function(e){return pt({category:"PNNetworkIssuesCategory"})})),Rt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),Rt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Rt.on(yt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("STOPPED");jt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(yt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Ct.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ht(e)})),xt.onExit((function(){return ht.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),xt.on(Et.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Nt.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[pt({category:"PNDisconnectedCategory"})])})),xt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])})),xt.on(vt.type,(function(e){return It.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt({category:"PNConnectedCategory"})})),It.onEnter((function(e){return ct(e.channels,e.groups,e.cursor)})),It.onExit((function(){return ct.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[lt(t.payload.events)])})),It.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ft(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return Rt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Dt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return ut(e.channels,e.groups)})),Gt.onExit((function(){return ut.cancel})),Gt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:e.timetoken&&"0"!==e.timetoken?e.timetoken:t.payload.timetoken,region:t.payload.region}})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups,r=e.timetoken;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(dt(this.channels,this.groups,null!=r?r:"0"))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(yt())},e.prototype.disconnect=function(){this.engine.transition(gt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(){}return e.getDelay=function(e,t,n){var r=null!=n?n:5;switch(e.toUpperCase()){case"LINEAR":return t*r+1e3*Math.random();case"EXPONENTIAL":return 1e3*Math.trunc(Math.pow(2,t-1))+1e3*Math.random();default:throw new Error("invalid policy")}},e}(),Bt=function(){function e(e){var t,r=this,i=e.networking,o=e.cbor,c=new g({setup:e});this._config=c;var l=new T({config:c}),p=e.cryptography;i.init(c);var h=new L(c,o);this._tokenManager=h;var f=new U({maximumSamplesCount:6e4});this._telemetryManager=f;var d={config:c,networking:i,crypto:l,cryptography:p,tokenManager:h,telemetryManager:f,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,t){return p.encryptFile(e,t,r.File)},this.decryptFile=function(e,t){return p.decryptFile(e,t,r.File)};var y=X.bind(this,d,Je),v=X.bind(this,d,ie),b=X.bind(this,d,se),m=X.bind(this,d,ue),_=X.bind(this,d,Xe),O=new F;if(this._listenerManager=O,this.iAmHere=X.bind(this,d,se),this.iAmAway=X.bind(this,d,ie),this.setPresenceState=X.bind(this,d,ue),this.handshake=X.bind(this,d,We),this.receiveMessages=X.bind(this,d,$e),!0===c.enableSubscribeBeta){var P=d.config.reconnectionConfiguration.reconnectionPolicy,S=null!==(t=d.config.reconnectionConfiguration.maximumReconnectionRetries)&&void 0!==t?t:0,w=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return Lt.getDelay(P,e)},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return S>t&&P&&"None"!=P},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;O.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){O.announceStatus(e)}});this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.unsubscribeAll=w.unsubscribeAll.bind(w),this.reconnect=w.reconnect.bind(w),this.disconnect=w.disconnect.bind(w),this.eventEngine=w}else{var k=new R({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:m,subscribeEndpoint:_,crypto:d.crypto,config:d.config,listenerManager:O,getFileUrl:function(e){return ve(d,e)}});this.subscribe=k.adaptSubscribeChange.bind(k),this.unsubscribe=k.adaptUnsubscribeChange.bind(k),this.disconnect=k.disconnect.bind(k),this.reconnect=k.reconnect.bind(k),this.unsubscribeAll=k.unsubscribeAll.bind(k),this.getSubscribedChannels=k.getSubscribedChannels.bind(k),this.getSubscribedChannelGroups=k.getSubscribedChannelGroups.bind(k),this.setState=k.adaptStateChange.bind(k),this.presence=k.adaptPresenceChange.bind(k),this.destroy=function(e){k.unsubscribeAll(e),k.disconnect()}}this.addListener=O.addListener.bind(O),this.removeListener=O.removeListener.bind(O),this.removeAllListeners=O.removeAllListeners.bind(O),this.parseToken=h.parseToken.bind(h),this.setToken=h.setToken.bind(h),this.getToken=h.getToken.bind(h),this.channelGroups={listGroups:X.bind(this,d,Y),listChannels:X.bind(this,d,Z),addChannels:X.bind(this,d,W),removeChannels:X.bind(this,d,$),deleteGroup:X.bind(this,d,Q)},this.push={addChannels:X.bind(this,d,ee),removeChannels:X.bind(this,d,te),deleteDevice:X.bind(this,d,re),listChannels:X.bind(this,d,ne)},this.hereNow=X.bind(this,d,ce),this.whereNow=X.bind(this,d,oe),this.getState=X.bind(this,d,ae),this.grant=X.bind(this,d,je),this.grantToken=X.bind(this,d,De),this.audit=X.bind(this,d,Re),this.revokeToken=X.bind(this,d,Ge),this.publish=X.bind(this,d,Fe),this.fire=function(e,t){return e.replicate=!1,e.storeInHistory=!1,r.publish(e,t)},this.signal=X.bind(this,d,Le),this.history=X.bind(this,d,He),this.deleteMessages=X.bind(this,d,qe),this.messageCounts=X.bind(this,d,ze),this.fetchMessages=X.bind(this,d,Ve),this.addMessageAction=X.bind(this,d,le),this.removeMessageAction=X.bind(this,d,pe),this.getMessageActions=X.bind(this,d,he),this.listFiles=X.bind(this,d,fe);var E=X.bind(this,d,de);this.publishFile=X.bind(this,d,ge),this.sendFile=ye({generateUploadUrl:E,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return ve(d,e)},this.downloadFile=X.bind(this,d,be),this.deleteFile=X.bind(this,d,me),this.objects={getAllUUIDMetadata:X.bind(this,d,_e),getUUIDMetadata:X.bind(this,d,Oe),setUUIDMetadata:X.bind(this,d,Pe),removeUUIDMetadata:X.bind(this,d,Se),getAllChannelMetadata:X.bind(this,d,we),getChannelMetadata:X.bind(this,d,Te),setChannelMetadata:X.bind(this,d,ke),removeChannelMetadata:X.bind(this,d,Ee),getChannelMembers:X.bind(this,d,Ne),setChannelMembers:function(e){for(var t=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function qt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?qt(s):s})),n}var zt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),Vt={exports:{}},Jt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function on(e,t,n,r){void 0===r&&(r=Zt());var i,o=sn(e,"",0,[],void 0,0,r)||e;try{i=0===Yt.length?JSON.stringify(o,t,n):JSON.stringify(o,an(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Qt.length;){var s=Qt.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function sn(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(dn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===hn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=gn[u]:u<2048?s+=gn[192|u>>6]+gn[128|63&u]:u<55296||u>=57344?s+=gn[224|u>>12]+gn[128|u>>6&63]+gn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=gn[240|u>>18]+gn[128|u>>12&63]+gn[128|u>>6&63]+gn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(dn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(Pn(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},In=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&Mn.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},Dn={formats:pn,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||An.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Rn(l)?[l]:l),Mn.call(r,c)?r[c]=An.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Gn(e){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gn(e)}var Kn=function(e){return null!==e&&"object"===Gn(e)};function Fn(e){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fn(e)}var Ln=Kn,Bn=Hn;function Hn(e){if(e)return function(e){for(var t in Hn.prototype)Object.prototype.hasOwnProperty.call(Hn.prototype,t)&&(e[t]=Hn.prototype[t]);return e}(e)}Hn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Hn.prototype.parse=function(e){return this._parser=e,this},Hn.prototype.responseType=function(e){return this._responseType=e,this},Hn.prototype.serialize=function(e){return this._serializer=e,this},Hn.prototype.timeout=function(e){if(!e||"object"!==Fn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Hn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var qn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),zn=new Set([408,413,429,500,502,503,504,521,522,524]);Hn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&zn.has(t.status))return!0;if(e){if(e.code&&qn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Hn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Hn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Hn.prototype.catch=function(e){return this.then(void 0,e)},Hn.prototype.use=function(e){return e(this),this},Hn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Hn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Hn.prototype.get=function(e){return this._header[e.toLowerCase()]},Hn.prototype.getHeader=Hn.prototype.get,Hn.prototype.set=function(e,t){if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Hn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Hn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Hn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Hn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Hn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Hn.prototype.redirects=function(e){return this._maxRedirects=e,this},Hn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Hn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Hn.prototype.send=function(e){var t=Ln(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Ln(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Hn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Hn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Hn.prototype._appendQueryString=function(){console.warn("Unsupported")},Hn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Hn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var Vn={};function Jn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Xn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(Vt,Vt.exports);var nr=Vt.exports;function rr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function ir(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(rr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function or(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=nr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function sr(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ar(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ur(e,t,n,r){var i=nr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function cr(e,t,n,r){var i=nr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function lr(e,t,n){var r=nr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function pr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var hr,fr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=pr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=pr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),dr=(hr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),hr.supportsFile="undefined"!=typeof File,hr.supportsBlob="undefined"!=typeof Blob,hr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,hr.supportsBuffer=!1,hr.supportsStream=!1,hr.supportsString=!0,hr.supportsEncryptFile=!0,hr.supportsFileUri=!1,hr);function gr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var yr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:lr,get:ar,post:ur,patch:cr,sendBeacon:gr,getfile:sr,postfile:or}),t.cbor=new zt((function(e){return qt(p.decode(e))}),y),t.PubNubFile=dr,t.cryptography=new fr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Bt);return yr})); diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index 657a1c46c..11df6967a 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -189,9 +189,9 @@ var default_1 = /** @class */ (function () { var eventEngine = new event_engine_1.EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return reconnectionDelay_1.ReconnectionDelay.getDelay(policy_1, maxRetries_1); }, + getRetryDelay: function (attempts) { return reconnectionDelay_1.ReconnectionDelay.getDelay(policy_1, attempts); }, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (_, attempts) { return maxRetries_1 >= attempts && policy_1 && policy_1 != 'None'; }, + shouldRetry: function (_, attempts) { return maxRetries_1 > attempts && policy_1 && policy_1 != 'None'; }, emitEvents: function (events) { var e_1, _a; try { diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index 480d0a945..caffec96f 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -5,7 +5,7 @@ var core_1 = require("./core"); exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ channels: channels, groups: groups, - timetoken: timetoken + timetoken: timetoken, }); }); exports.disconnect = (0, core_1.createEvent)('DISCONNECT', function () { return ({}); }); exports.reconnect = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); @@ -17,11 +17,11 @@ exports.restore = (0, core_1.createEvent)('RESTORE', function (channels, groups, }); }); exports.handshakingSuccess = (0, core_1.createEvent)('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); exports.handshakingFailure = (0, core_1.createEvent)('HANDSHAKE_FAILURE', function (error) { return error; }); -exports.handshakingReconnectingSuccess = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_SUCCESS', function (cursor) { return ({ +exports.handshakingReconnectingSuccess = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_SUCCESS', function (cursor) { return ({ cursor: cursor, }); }); exports.handshakingReconnectingFailure = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); -exports.handshakingReconnectingGiveup = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_GIVEUP', function () { return ({}); }); +exports.handshakingReconnectingGiveup = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_GIVEUP', function () { return ({}); }); exports.handshakingReconnectingRetry = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_RETRY', function () { return ({}); }); exports.receivingSuccess = (0, core_1.createEvent)('RECEIVE_SUCCESS', function (cursor, events) { return ({ cursor: cursor, diff --git a/lib/event-engine/states/unsubscribed.js b/lib/event-engine/states/unsubscribed.js index 4f1523a48..dcca75e04 100644 --- a/lib/event-engine/states/unsubscribed.js +++ b/lib/event-engine/states/unsubscribed.js @@ -6,5 +6,9 @@ var events_1 = require("../events"); var handshaking_1 = require("./handshaking"); exports.UnsubscribedState = new state_1.State('UNSUBSCRIBED'); exports.UnsubscribedState.on(events_1.subscriptionChange.type, function (_, event) { - return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, timetoken: event.payload.timetoken }); + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); }); diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 9688c379c..7e31f84dd 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -326,9 +326,9 @@ export default class { const eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: (attempts) => ReconnectionDelay.getDelay(policy, maxRetries), + getRetryDelay: (attempts) => ReconnectionDelay.getDelay(policy, attempts), delay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), - shouldRetry: (_, attempts) => maxRetries >= attempts && policy && policy != 'None', + shouldRetry: (_, attempts) => maxRetries > attempts && policy && policy != 'None', emitEvents: (events) => { for (const event of events) { listenerManager.announceMessage(event); diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index c95a4c9e2..45a52974b 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -26,11 +26,11 @@ export const restore = createEvent( export const handshakingSuccess = createEvent('HANDSHAKE_SUCCESS', (cursor: Cursor) => cursor); export const handshakingFailure = createEvent('HANDSHAKE_FAILURE', (error: PubNubError) => error); -export const handshakingReconnectingSuccess = createEvent('HANDSHAKING_RECONNECTING_SUCCESS', (cursor: Cursor) => ({ +export const handshakingReconnectingSuccess = createEvent('HANDSHAKE_RECONNECT_SUCCESS', (cursor: Cursor) => ({ cursor, })); export const handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', (error: PubNubError) => error); -export const handshakingReconnectingGiveup = createEvent('HANDSHAKING_RECONNECTING_GIVEUP', () => ({})); +export const handshakingReconnectingGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', () => ({})); export const handshakingReconnectingRetry = createEvent('HANDSHAKING_RECONNECTING_RETRY', () => ({})); export const receivingSuccess = createEvent('RECEIVE_SUCCESS', (cursor: Cursor, events: any[]) => ({ diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index 6900e88e8..5bb58e259 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -16,7 +16,6 @@ export const ReceivingState = new State( ReceivingState.onEnter((_) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onEnter((context) => receiveEvents(context.channels, context.groups, context.cursor)); -ReceivingState.onEnter((_) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onExit(() => receiveEvents.cancel); ReceivingState.on(receivingSuccess.type, (context, event) => { From 701a44f5ea426085d786c4aaf3b0769782a0720d Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 18 Aug 2023 12:15:35 +0530 Subject: [PATCH 17/63] WIP: presence event engine --- src/event-engine/presence/presence.ts | 21 ++++++ .../presence/presence_dispatcher.ts | 73 +++++++++++++++++++ src/event-engine/presence/presence_effects.ts | 18 +++++ src/event-engine/presence/presence_events.ts | 44 +++++++++++ .../presence_states/heartbeat_cooldown.ts | 18 +++++ .../presence_states/heartbeat_inactive.ts | 13 ++++ .../presence_states/heartbeat_reconnecting.ts | 12 +++ .../presence_states/heartbeat_stopped.ts | 0 .../presence/presence_states/heartbeating.ts | 45 ++++++++++++ 9 files changed, 244 insertions(+) create mode 100644 src/event-engine/presence/presence.ts create mode 100644 src/event-engine/presence/presence_dispatcher.ts create mode 100644 src/event-engine/presence/presence_effects.ts create mode 100644 src/event-engine/presence/presence_events.ts create mode 100644 src/event-engine/presence/presence_states/heartbeat_cooldown.ts create mode 100644 src/event-engine/presence/presence_states/heartbeat_inactive.ts create mode 100644 src/event-engine/presence/presence_states/heartbeat_reconnecting.ts create mode 100644 src/event-engine/presence/presence_states/heartbeat_stopped.ts create mode 100644 src/event-engine/presence/presence_states/heartbeating.ts diff --git a/src/event-engine/presence/presence.ts b/src/event-engine/presence/presence.ts new file mode 100644 index 000000000..80bb402f0 --- /dev/null +++ b/src/event-engine/presence/presence.ts @@ -0,0 +1,21 @@ +import { Dispatcher, Engine } from "../core" +import * as events from "./presence_events" +import * as effects from "./presence_effects" +import { Dependencies, PresenceEventEngineDispatcher } from "./presence_dispatcher"; + +export class PresenceEventEngine { + private engine: Engine = new Engine(); + private dispatcher: Dispatcher; + + get _engine() { + return this.engine; + } + + /** + * + */ + constructor(dependencies: Dependencies) { + this.dispatcher = new PresenceEventEngineDispatcher(this.engine, dependencies); + + } +} \ No newline at end of file diff --git a/src/event-engine/presence/presence_dispatcher.ts b/src/event-engine/presence/presence_dispatcher.ts new file mode 100644 index 000000000..9904e68b0 --- /dev/null +++ b/src/event-engine/presence/presence_dispatcher.ts @@ -0,0 +1,73 @@ +import { PubNubError } from '../../core/components/endpoint'; +import { asyncHandler, Dispatcher, Engine } from '../core'; +import * as effects from './presence_effects' +import * as events from './presence_events' + + +export type Dependencies = { + heartbeat: any; + leave: any; + heartbeatDelay: (millisecond: number) => Promise; + getDelayTime: () => number; // gets value from configuration +} + +export class PresenceEventEngineDispatcher extends Dispatcher { + /** + * Effect Dispatcher for presence events + */ + constructor(engine: Engine, dependencies: Dependencies) { + super(dependencies); + + this.on( + effects.heartbeat.type, + asyncHandler(async (payload, _, { heartbeat })=> { + + try { + const result = await heartbeat({ + channels: payload.channels, + channelGroups: payload.groups, + }); + + engine.transition(events.heartbeatSuccess()); + } catch (e) { + if (e instanceof PubNubError) { + return engine.transition(events.heartbeatFailure(e)); + } + } + }) + ); + + this.on( + effects.leave.type, + asyncHandler(async (payload, _, { leave })=> { + + try { + const result = await leave({ + channels: payload.channels, + channelGroups: payload.groups, + }); + + engine.transition(events.leaveSuccess()); + } catch (e) { + if (e instanceof PubNubError) { + return engine.transition(events.leaveFailure(e)); + } + } + }) + ); + + this.on( + effects.wait.type, + asyncHandler(async (_, abortSignal, { heartbeatDelay, getDelayTime }) => { + + abortSignal.throwIfAborted(); + + await heartbeatDelay(getDelayTime()); + + abortSignal.throwIfAborted(); + + return engine.transition(events.leaveSuccess()); + }), + ); + } +} \ No newline at end of file diff --git a/src/event-engine/presence/presence_effects.ts b/src/event-engine/presence/presence_effects.ts new file mode 100644 index 000000000..5f0f3518f --- /dev/null +++ b/src/event-engine/presence/presence_effects.ts @@ -0,0 +1,18 @@ +import { createEffect, createManagedEffect, MapOf } from "../core"; + +export const heartbeat = createEffect('HEARTBEAT', (channels: string[], groups: string[]) => ({ + channels, + groups, +})); + +export const leave = createEffect('LEAVE', (channels: string[], groups: string[]) => ({ + channels, + groups, +})); + +export const wait = createManagedEffect('WAIT', () => {}) + +export type Effects = MapOf< + | typeof heartbeat + | typeof leave + | typeof wait>; \ No newline at end of file diff --git a/src/event-engine/presence/presence_events.ts b/src/event-engine/presence/presence_events.ts new file mode 100644 index 000000000..70e056324 --- /dev/null +++ b/src/event-engine/presence/presence_events.ts @@ -0,0 +1,44 @@ +import { PubNubError } from "../core/components/endpoint"; +import { createEvent, MapOf } from "./core"; + +export const disconnect = createEvent('DISCONNECT', () => ({})); + +export const joined = createEvent( + 'JOINED', + (channels: string[], groups: string[]) => ({ + channels, + groups, + }), +); + +export const left = createEvent( + 'LEFT', + (channels: string[], groups: string[]) => ({ + channels, + groups, + }), +); + +export const leftAll = createEvent('LEFT_ALL', () => ({})); + +export const heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', () => ({})); + +export const heartbeatFailure = createEvent('HEARTBEAT_FAILURE', (error: PubNubError) => error); + +export const leaveSuccess = createEvent('LEAVE_SUCCESS', () => {}); + +export const leaveFailure = createEvent('LEAVE_FAILURE', (error: PubNubError) => error); + +export const timesUp = createEvent('TIMES_UP', () => {}); + +export type Events = MapOf< + | typeof disconnect + | typeof leftAll + | typeof heartbeatSuccess + | typeof heartbeatFailure + | typeof leaveSuccess + | typeof leaveFailure + | typeof joined + | typeof left + | typeof timesUp +>; diff --git a/src/event-engine/presence/presence_states/heartbeat_cooldown.ts b/src/event-engine/presence/presence_states/heartbeat_cooldown.ts new file mode 100644 index 000000000..a649cfea9 --- /dev/null +++ b/src/event-engine/presence/presence_states/heartbeat_cooldown.ts @@ -0,0 +1,18 @@ +import { State } from '../../core/state'; +import { Events, timesUp } from '../presence_events'; +import { Effects } from '../presence_effects'; +import { HeartbeatingState } from './heartbeating'; + +export type HeartbeatCooldownStateContext = { + channels: string[]; + groups: string[]; +}; + +export const HeartbeatCooldownState = new State('HEARTBEATCOOLDOWN'); + +HeartbeatCooldownState.on(timesUp.type, (context, event) => + HeartbeatingState.with({ + channels: context.channels, + groups: context.groups + }) +); diff --git a/src/event-engine/presence/presence_states/heartbeat_inactive.ts b/src/event-engine/presence/presence_states/heartbeat_inactive.ts new file mode 100644 index 000000000..7453c49e1 --- /dev/null +++ b/src/event-engine/presence/presence_states/heartbeat_inactive.ts @@ -0,0 +1,13 @@ +import { State } from '../core/state'; +import { Effects } from '../presence_effects'; +import { Events, joined } from '../presence_events'; +import { HeartbeatingState } from './heartbeating'; + +export const HeartbeatInactiveState = new State('HEARTBEAT_INACTIVE'); + +HeartbeatInactiveState.on(joined.type, (_, event) => + HeartbeatingState.with({ + channels: event.payload.channels, + groups: event.payload.groups + }), +); \ No newline at end of file diff --git a/src/event-engine/presence/presence_states/heartbeat_reconnecting.ts b/src/event-engine/presence/presence_states/heartbeat_reconnecting.ts new file mode 100644 index 000000000..843e5eb4d --- /dev/null +++ b/src/event-engine/presence/presence_states/heartbeat_reconnecting.ts @@ -0,0 +1,12 @@ +import { State } from '../../core/state'; +import { Events } from '../presence_events'; +import { Effects } from '../presence_effects'; + +export type HeartbeatReconnectingStateContext = { + channels: string[]; + groups: string[]; +}; + + +export const HearbeatReconnectingState = new State('HEARBEAT_RECONNECTING'); + diff --git a/src/event-engine/presence/presence_states/heartbeat_stopped.ts b/src/event-engine/presence/presence_states/heartbeat_stopped.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/event-engine/presence/presence_states/heartbeating.ts b/src/event-engine/presence/presence_states/heartbeating.ts new file mode 100644 index 000000000..90b4a744c --- /dev/null +++ b/src/event-engine/presence/presence_states/heartbeating.ts @@ -0,0 +1,45 @@ +import { State } from '../../core/state'; +import { Events, heartbeatFailure, heartbeatSuccess, joined, left } from '../presence_events'; +import { Effects, heartbeat, leave } from '../presence_effects'; +import { HeartbeatCooldownState } from './heartbeat_cooldown'; +import { HearbeatReconnectingState } from './heartbeat_reconnecting'; + +export type HeartbeatingStateContext = { + channels: string[]; + groups: string[]; +}; + +export const HeartbeatingState = new State ('HEARTBEATING'); + +HeartbeatingState.onEnter((context) => heartbeat(context.channels, context.groups)); +// HeartbeatingState.onExit(() => heartbeat.cancel); + +HeartbeatingState.on(heartbeatSuccess.type, (context, _) => { + return HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups + }); +}); + +HeartbeatingState.on(joined.type, (context, event) => HeartbeatingState.with({ + channels: [...context.channels, ...event.payload.channels], + groups: [...context.groups, ...event.payload.groups] + }) +); + +HeartbeatingState.on(left.type, (context, event) => + HeartbeatingState.with( + { + channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), + groups: context.groups.filter((group) => !event.payload.groups.includes(group)), + }, + [leave(event.payload.channels, event.payload.groups)], + ), +); + +HeartbeatingState.on(heartbeatFailure.type, (context, event) => + HearbeatReconnectingState.with({ + channels: context.channels, + groups: context.groups, + }), +); \ No newline at end of file From b377b3c824842c5113b375285e72b2c6406d152c Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 18 Aug 2023 12:41:32 +0530 Subject: [PATCH 18/63] organised files and directories for presence --- .../presence/{presence_dispatcher.ts => dispatcher.ts} | 4 ++-- .../presence/{presence_effects.ts => effects.ts} | 0 src/event-engine/presence/{presence_events.ts => events.ts} | 4 ++-- src/event-engine/presence/presence.ts | 6 +++--- .../{presence_states => states}/heartbeat_cooldown.ts | 4 ++-- .../{presence_states => states}/heartbeat_inactive.ts | 4 ++-- .../{presence_states => states}/heartbeat_reconnecting.ts | 4 ++-- .../{presence_states => states}/heartbeat_stopped.ts | 0 .../presence/{presence_states => states}/heartbeating.ts | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) rename src/event-engine/presence/{presence_dispatcher.ts => dispatcher.ts} (95%) rename src/event-engine/presence/{presence_effects.ts => effects.ts} (100%) rename src/event-engine/presence/{presence_events.ts => events.ts} (90%) rename src/event-engine/presence/{presence_states => states}/heartbeat_cooldown.ts (82%) rename src/event-engine/presence/{presence_states => states}/heartbeat_inactive.ts (77%) rename src/event-engine/presence/{presence_states => states}/heartbeat_reconnecting.ts (74%) rename src/event-engine/presence/{presence_states => states}/heartbeat_stopped.ts (100%) rename src/event-engine/presence/{presence_states => states}/heartbeating.ts (93%) diff --git a/src/event-engine/presence/presence_dispatcher.ts b/src/event-engine/presence/dispatcher.ts similarity index 95% rename from src/event-engine/presence/presence_dispatcher.ts rename to src/event-engine/presence/dispatcher.ts index 9904e68b0..d45dc346e 100644 --- a/src/event-engine/presence/presence_dispatcher.ts +++ b/src/event-engine/presence/dispatcher.ts @@ -1,7 +1,7 @@ import { PubNubError } from '../../core/components/endpoint'; import { asyncHandler, Dispatcher, Engine } from '../core'; -import * as effects from './presence_effects' -import * as events from './presence_events' +import * as effects from './effects' +import * as events from './events' export type Dependencies = { diff --git a/src/event-engine/presence/presence_effects.ts b/src/event-engine/presence/effects.ts similarity index 100% rename from src/event-engine/presence/presence_effects.ts rename to src/event-engine/presence/effects.ts diff --git a/src/event-engine/presence/presence_events.ts b/src/event-engine/presence/events.ts similarity index 90% rename from src/event-engine/presence/presence_events.ts rename to src/event-engine/presence/events.ts index 70e056324..75c170be9 100644 --- a/src/event-engine/presence/presence_events.ts +++ b/src/event-engine/presence/events.ts @@ -1,5 +1,5 @@ -import { PubNubError } from "../core/components/endpoint"; -import { createEvent, MapOf } from "./core"; +import { PubNubError } from "../../core/components/endpoint"; +import { createEvent, MapOf } from "../core"; export const disconnect = createEvent('DISCONNECT', () => ({})); diff --git a/src/event-engine/presence/presence.ts b/src/event-engine/presence/presence.ts index 80bb402f0..d8709904f 100644 --- a/src/event-engine/presence/presence.ts +++ b/src/event-engine/presence/presence.ts @@ -1,7 +1,7 @@ import { Dispatcher, Engine } from "../core" -import * as events from "./presence_events" -import * as effects from "./presence_effects" -import { Dependencies, PresenceEventEngineDispatcher } from "./presence_dispatcher"; +import * as events from "./events" +import * as effects from "./effects" +import { Dependencies, PresenceEventEngineDispatcher } from "./dispatcher"; export class PresenceEventEngine { private engine: Engine = new Engine(); diff --git a/src/event-engine/presence/presence_states/heartbeat_cooldown.ts b/src/event-engine/presence/states/heartbeat_cooldown.ts similarity index 82% rename from src/event-engine/presence/presence_states/heartbeat_cooldown.ts rename to src/event-engine/presence/states/heartbeat_cooldown.ts index a649cfea9..e33766358 100644 --- a/src/event-engine/presence/presence_states/heartbeat_cooldown.ts +++ b/src/event-engine/presence/states/heartbeat_cooldown.ts @@ -1,6 +1,6 @@ import { State } from '../../core/state'; -import { Events, timesUp } from '../presence_events'; -import { Effects } from '../presence_effects'; +import { Events, timesUp } from '../events'; +import { Effects } from '../effects'; import { HeartbeatingState } from './heartbeating'; export type HeartbeatCooldownStateContext = { diff --git a/src/event-engine/presence/presence_states/heartbeat_inactive.ts b/src/event-engine/presence/states/heartbeat_inactive.ts similarity index 77% rename from src/event-engine/presence/presence_states/heartbeat_inactive.ts rename to src/event-engine/presence/states/heartbeat_inactive.ts index 7453c49e1..e92c90104 100644 --- a/src/event-engine/presence/presence_states/heartbeat_inactive.ts +++ b/src/event-engine/presence/states/heartbeat_inactive.ts @@ -1,6 +1,6 @@ import { State } from '../core/state'; -import { Effects } from '../presence_effects'; -import { Events, joined } from '../presence_events'; +import { Effects } from '../effects'; +import { Events, joined } from '../events'; import { HeartbeatingState } from './heartbeating'; export const HeartbeatInactiveState = new State('HEARTBEAT_INACTIVE'); diff --git a/src/event-engine/presence/presence_states/heartbeat_reconnecting.ts b/src/event-engine/presence/states/heartbeat_reconnecting.ts similarity index 74% rename from src/event-engine/presence/presence_states/heartbeat_reconnecting.ts rename to src/event-engine/presence/states/heartbeat_reconnecting.ts index 843e5eb4d..f725e0ec3 100644 --- a/src/event-engine/presence/presence_states/heartbeat_reconnecting.ts +++ b/src/event-engine/presence/states/heartbeat_reconnecting.ts @@ -1,6 +1,6 @@ import { State } from '../../core/state'; -import { Events } from '../presence_events'; -import { Effects } from '../presence_effects'; +import { Events } from '../events'; +import { Effects } from '../effects'; export type HeartbeatReconnectingStateContext = { channels: string[]; diff --git a/src/event-engine/presence/presence_states/heartbeat_stopped.ts b/src/event-engine/presence/states/heartbeat_stopped.ts similarity index 100% rename from src/event-engine/presence/presence_states/heartbeat_stopped.ts rename to src/event-engine/presence/states/heartbeat_stopped.ts diff --git a/src/event-engine/presence/presence_states/heartbeating.ts b/src/event-engine/presence/states/heartbeating.ts similarity index 93% rename from src/event-engine/presence/presence_states/heartbeating.ts rename to src/event-engine/presence/states/heartbeating.ts index 90b4a744c..32fd92ff1 100644 --- a/src/event-engine/presence/presence_states/heartbeating.ts +++ b/src/event-engine/presence/states/heartbeating.ts @@ -1,6 +1,6 @@ import { State } from '../../core/state'; -import { Events, heartbeatFailure, heartbeatSuccess, joined, left } from '../presence_events'; -import { Effects, heartbeat, leave } from '../presence_effects'; +import { Events, heartbeatFailure, heartbeatSuccess, joined, left } from '../events'; +import { Effects, heartbeat, leave } from '../effects'; import { HeartbeatCooldownState } from './heartbeat_cooldown'; import { HearbeatReconnectingState } from './heartbeat_reconnecting'; From 90961004d446e2b0b0def56d5a6c145726873326 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 18 Aug 2023 12:45:07 +0530 Subject: [PATCH 19/63] fix: paths --- src/event-engine/presence/states/heartbeat_inactive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/event-engine/presence/states/heartbeat_inactive.ts b/src/event-engine/presence/states/heartbeat_inactive.ts index e92c90104..cfbef4fcb 100644 --- a/src/event-engine/presence/states/heartbeat_inactive.ts +++ b/src/event-engine/presence/states/heartbeat_inactive.ts @@ -1,11 +1,11 @@ -import { State } from '../core/state'; +import { State } from '../../core/state'; import { Effects } from '../effects'; import { Events, joined } from '../events'; import { HeartbeatingState } from './heartbeating'; export const HeartbeatInactiveState = new State('HEARTBEAT_INACTIVE'); -HeartbeatInactiveState.on(joined.type, (_, event) => +HeartbeatInactiveState.on(joined.type, (context, event) => HeartbeatingState.with({ channels: event.payload.channels, groups: event.payload.groups From 325fd524057a69d7158c73425b238d23e96c49f1 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 22 Aug 2023 11:44:09 +0530 Subject: [PATCH 20/63] fix: lint --- src/event-engine/presence/dispatcher.ts | 48 +++++++++---------- src/event-engine/presence/effects.ts | 9 ++-- src/event-engine/presence/events.ts | 32 +++++-------- src/event-engine/presence/presence.ts | 11 ++--- .../presence/states/heartbeat_cooldown.ts | 6 +-- .../presence/states/heartbeat_inactive.ts | 6 +-- .../presence/states/heartbeat_reconnecting.ts | 6 +-- .../presence/states/heartbeating.ts | 15 +++--- 8 files changed, 60 insertions(+), 73 deletions(-) diff --git a/src/event-engine/presence/dispatcher.ts b/src/event-engine/presence/dispatcher.ts index d45dc346e..9fd305f27 100644 --- a/src/event-engine/presence/dispatcher.ts +++ b/src/event-engine/presence/dispatcher.ts @@ -1,15 +1,14 @@ import { PubNubError } from '../../core/components/endpoint'; import { asyncHandler, Dispatcher, Engine } from '../core'; -import * as effects from './effects' -import * as events from './events' - +import * as effects from './effects'; +import * as events from './events'; export type Dependencies = { heartbeat: any; leave: any; heartbeatDelay: (millisecond: number) => Promise; - getDelayTime: () => number; // gets value from configuration -} + getDelayTime: () => number; // gets value from configuration +}; export class PresenceEventEngineDispatcher extends Dispatcher { /** @@ -17,11 +16,10 @@ export class PresenceEventEngineDispatcher extends Dispatcher, dependencies: Dependencies) { super(dependencies); - + this.on( effects.heartbeat.type, - asyncHandler(async (payload, _, { heartbeat })=> { - + asyncHandler(async (payload, _, { heartbeat }) => { try { const result = await heartbeat({ channels: payload.channels, @@ -30,44 +28,42 @@ export class PresenceEventEngineDispatcher extends Dispatcher { - + asyncHandler(async (payload, _, { leave }) => { try { const result = await leave({ channels: payload.channels, channelGroups: payload.groups, }); - engine.transition(events.leaveSuccess()); + // engine.transition(events.leaveSuccess()); } catch (e) { - if (e instanceof PubNubError) { - return engine.transition(events.leaveFailure(e)); - } + if (e instanceof PubNubError) { + // return engine.transition(events.leaveFailure(e)); + } } - }) + }), ); this.on( effects.wait.type, asyncHandler(async (_, abortSignal, { heartbeatDelay, getDelayTime }) => { - - abortSignal.throwIfAborted(); + abortSignal.throwIfAborted(); - await heartbeatDelay(getDelayTime()); - - abortSignal.throwIfAborted(); + await heartbeatDelay(getDelayTime()); - return engine.transition(events.leaveSuccess()); + abortSignal.throwIfAborted(); + + return engine.transition(events.leaveSuccess()); }), ); } -} \ No newline at end of file +} diff --git a/src/event-engine/presence/effects.ts b/src/event-engine/presence/effects.ts index 5f0f3518f..06c8b285e 100644 --- a/src/event-engine/presence/effects.ts +++ b/src/event-engine/presence/effects.ts @@ -1,4 +1,4 @@ -import { createEffect, createManagedEffect, MapOf } from "../core"; +import { createEffect, createManagedEffect, MapOf } from '../core'; export const heartbeat = createEffect('HEARTBEAT', (channels: string[], groups: string[]) => ({ channels, @@ -10,9 +10,6 @@ export const leave = createEffect('LEAVE', (channels: string[], groups: string[] groups, })); -export const wait = createManagedEffect('WAIT', () => {}) +export const wait = createManagedEffect('WAIT', () => ({})); -export type Effects = MapOf< - | typeof heartbeat - | typeof leave - | typeof wait>; \ No newline at end of file +export type Effects = MapOf; diff --git a/src/event-engine/presence/events.ts b/src/event-engine/presence/events.ts index 75c170be9..8bf539dd9 100644 --- a/src/event-engine/presence/events.ts +++ b/src/event-engine/presence/events.ts @@ -1,23 +1,17 @@ -import { PubNubError } from "../../core/components/endpoint"; -import { createEvent, MapOf } from "../core"; +import { PubNubError } from '../../core/components/endpoint'; +import { createEvent, MapOf } from '../core'; export const disconnect = createEvent('DISCONNECT', () => ({})); -export const joined = createEvent( - 'JOINED', - (channels: string[], groups: string[]) => ({ - channels, - groups, - }), -); - -export const left = createEvent( - 'LEFT', - (channels: string[], groups: string[]) => ({ - channels, - groups, - }), -); +export const joined = createEvent('JOINED', (channels: string[], groups: string[]) => ({ + channels, + groups, +})); + +export const left = createEvent('LEFT', (channels: string[], groups: string[]) => ({ + channels, + groups, +})); export const leftAll = createEvent('LEFT_ALL', () => ({})); @@ -25,11 +19,11 @@ export const heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', () => ({})); export const heartbeatFailure = createEvent('HEARTBEAT_FAILURE', (error: PubNubError) => error); -export const leaveSuccess = createEvent('LEAVE_SUCCESS', () => {}); +export const leaveSuccess = createEvent('LEAVE_SUCCESS', () => ({})); export const leaveFailure = createEvent('LEAVE_FAILURE', (error: PubNubError) => error); -export const timesUp = createEvent('TIMES_UP', () => {}); +export const timesUp = createEvent('TIMES_UP', () => ({})); export type Events = MapOf< | typeof disconnect diff --git a/src/event-engine/presence/presence.ts b/src/event-engine/presence/presence.ts index d8709904f..cb47a05ea 100644 --- a/src/event-engine/presence/presence.ts +++ b/src/event-engine/presence/presence.ts @@ -1,7 +1,7 @@ -import { Dispatcher, Engine } from "../core" -import * as events from "./events" -import * as effects from "./effects" -import { Dependencies, PresenceEventEngineDispatcher } from "./dispatcher"; +import { Dispatcher, Engine } from '../core'; +import * as events from './events'; +import * as effects from './effects'; +import { Dependencies, PresenceEventEngineDispatcher } from './dispatcher'; export class PresenceEventEngine { private engine: Engine = new Engine(); @@ -16,6 +16,5 @@ export class PresenceEventEngine { */ constructor(dependencies: Dependencies) { this.dispatcher = new PresenceEventEngineDispatcher(this.engine, dependencies); - } -} \ No newline at end of file +} diff --git a/src/event-engine/presence/states/heartbeat_cooldown.ts b/src/event-engine/presence/states/heartbeat_cooldown.ts index e33766358..710e0d36b 100644 --- a/src/event-engine/presence/states/heartbeat_cooldown.ts +++ b/src/event-engine/presence/states/heartbeat_cooldown.ts @@ -10,9 +10,9 @@ export type HeartbeatCooldownStateContext = { export const HeartbeatCooldownState = new State('HEARTBEATCOOLDOWN'); -HeartbeatCooldownState.on(timesUp.type, (context, event) => +HeartbeatCooldownState.on(timesUp.type, (context, event) => HeartbeatingState.with({ channels: context.channels, - groups: context.groups - }) + groups: context.groups, + }), ); diff --git a/src/event-engine/presence/states/heartbeat_inactive.ts b/src/event-engine/presence/states/heartbeat_inactive.ts index cfbef4fcb..44d9f1d02 100644 --- a/src/event-engine/presence/states/heartbeat_inactive.ts +++ b/src/event-engine/presence/states/heartbeat_inactive.ts @@ -5,9 +5,9 @@ import { HeartbeatingState } from './heartbeating'; export const HeartbeatInactiveState = new State('HEARTBEAT_INACTIVE'); -HeartbeatInactiveState.on(joined.type, (context, event) => +HeartbeatInactiveState.on(joined.type, (context, event) => HeartbeatingState.with({ channels: event.payload.channels, - groups: event.payload.groups + groups: event.payload.groups, }), -); \ No newline at end of file +); diff --git a/src/event-engine/presence/states/heartbeat_reconnecting.ts b/src/event-engine/presence/states/heartbeat_reconnecting.ts index f725e0ec3..8747194a1 100644 --- a/src/event-engine/presence/states/heartbeat_reconnecting.ts +++ b/src/event-engine/presence/states/heartbeat_reconnecting.ts @@ -7,6 +7,6 @@ export type HeartbeatReconnectingStateContext = { groups: string[]; }; - -export const HearbeatReconnectingState = new State('HEARBEAT_RECONNECTING'); - +export const HearbeatReconnectingState = new State( + 'HEARBEAT_RECONNECTING', +); diff --git a/src/event-engine/presence/states/heartbeating.ts b/src/event-engine/presence/states/heartbeating.ts index 32fd92ff1..aa4d19999 100644 --- a/src/event-engine/presence/states/heartbeating.ts +++ b/src/event-engine/presence/states/heartbeating.ts @@ -9,7 +9,7 @@ export type HeartbeatingStateContext = { groups: string[]; }; -export const HeartbeatingState = new State ('HEARTBEATING'); +export const HeartbeatingState = new State('HEARTBEATING'); HeartbeatingState.onEnter((context) => heartbeat(context.channels, context.groups)); // HeartbeatingState.onExit(() => heartbeat.cancel); @@ -17,14 +17,15 @@ HeartbeatingState.onEnter((context) => heartbeat(context.channels, context.group HeartbeatingState.on(heartbeatSuccess.type, (context, _) => { return HeartbeatCooldownState.with({ channels: context.channels, - groups: context.groups + groups: context.groups, }); }); -HeartbeatingState.on(joined.type, (context, event) => HeartbeatingState.with({ - channels: [...context.channels, ...event.payload.channels], - groups: [...context.groups, ...event.payload.groups] - }) +HeartbeatingState.on(joined.type, (context, event) => + HeartbeatingState.with({ + channels: [...context.channels, ...event.payload.channels], + groups: [...context.groups, ...event.payload.groups], + }), ); HeartbeatingState.on(left.type, (context, event) => @@ -42,4 +43,4 @@ HeartbeatingState.on(heartbeatFailure.type, (context, event) => channels: context.channels, groups: context.groups, }), -); \ No newline at end of file +); From bb6809e777e7352596d597f464676de7b64167ed Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:24:29 +0530 Subject: [PATCH 21/63] presence and subscribe event engine states --- .../presence/states/heartbeat_cooldown.ts | 42 ++++++++++- .../presence/states/heartbeat_failed.ts | 51 +++++++++++++ .../presence/states/heartbeat_inactive.ts | 6 +- .../presence/states/heartbeat_reconnecting.ts | 74 ++++++++++++++++++- .../presence/states/heartbeat_stopped.ts | 50 +++++++++++++ .../presence/states/heartbeating.ts | 34 ++++++--- src/event-engine/states/handshake_failure.ts | 13 +--- .../states/handshake_reconnecting.ts | 57 +++++++++----- src/event-engine/states/handshake_stopped.ts | 2 +- src/event-engine/states/handshaking.ts | 40 +++++++--- src/event-engine/states/receive_failure.ts | 35 +++++++-- .../states/receive_reconnecting.ts | 22 ++++-- src/event-engine/states/receive_stopped.ts | 21 +++++- src/event-engine/states/receiving.ts | 20 +++-- src/event-engine/states/unsubscribed.ts | 10 ++- 15 files changed, 402 insertions(+), 75 deletions(-) create mode 100644 src/event-engine/presence/states/heartbeat_failed.ts diff --git a/src/event-engine/presence/states/heartbeat_cooldown.ts b/src/event-engine/presence/states/heartbeat_cooldown.ts index 710e0d36b..fb613e463 100644 --- a/src/event-engine/presence/states/heartbeat_cooldown.ts +++ b/src/event-engine/presence/states/heartbeat_cooldown.ts @@ -1,7 +1,9 @@ import { State } from '../../core/state'; -import { Events, timesUp } from '../events'; -import { Effects } from '../effects'; +import { Events, disconnect, joined, left, leftAll, timesUp } from '../events'; +import { Effects, leave, wait } from '../effects'; import { HeartbeatingState } from './heartbeating'; +import { HeartbeatStoppedState } from './heartbeat_stopped'; +import { HeartbeatInactiveState } from './heartbeat_inactive'; export type HeartbeatCooldownStateContext = { channels: string[]; @@ -10,9 +12,43 @@ export type HeartbeatCooldownStateContext = { export const HeartbeatCooldownState = new State('HEARTBEATCOOLDOWN'); -HeartbeatCooldownState.on(timesUp.type, (context, event) => +HeartbeatCooldownState.onEnter(() => wait()); +HeartbeatCooldownState.onExit(() => wait.cancel); + +HeartbeatCooldownState.on(timesUp.type, (context, _) => HeartbeatingState.with({ channels: context.channels, groups: context.groups, }), ); + +HeartbeatCooldownState.on(joined.type, (context, event) => + HeartbeatingState.with({ + channels: [...context.channels, ...event.payload.channels], + groups: [...context.groups, ...event.payload.groups], + }), +); + +HeartbeatCooldownState.on(left.type, (context, event) => + HeartbeatingState.with( + { + channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), + groups: context.groups.filter((group) => !event.payload.groups.includes(group)), + }, + [leave(event.payload.channels, event.payload.groups)], + ), +); + +HeartbeatCooldownState.on(disconnect.type, (context) => + HeartbeatStoppedState.with( + { + channels: context.channels, + groups: context.groups, + }, + [leave(context.channels, context.groups)], + ), +); + +HeartbeatCooldownState.on(leftAll.type, (context, _) => + HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]), +); diff --git a/src/event-engine/presence/states/heartbeat_failed.ts b/src/event-engine/presence/states/heartbeat_failed.ts new file mode 100644 index 000000000..628d309ad --- /dev/null +++ b/src/event-engine/presence/states/heartbeat_failed.ts @@ -0,0 +1,51 @@ +import { State } from '../../core/state'; +import { Events, disconnect, heartbeatFailure, heartbeatSuccess, joined, left, leftAll, reconnect } from '../events'; +import { Effects, heartbeat, leave } from '../effects'; +import { HeartbeatingState } from './heartbeating'; +import { HeartbeatStoppedState } from './heartbeat_stopped'; +import { HeartbeatInactiveState } from './heartbeat_inactive'; + +export type HeartbeatFailedStateContext = { + channels: string[]; + groups: string[]; +}; + +export const HeartbeatFailedState = new State('HEARTBEAT_FAILED'); + +HeartbeatFailedState.on(joined.type, (context, event) => + HeartbeatingState.with({ + channels: [...context.channels, ...event.payload.channels], + groups: [...context.groups, ...event.payload.groups], + }), +); + +HeartbeatFailedState.on(left.type, (context, event) => + HeartbeatingState.with( + { + channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), + groups: context.groups.filter((group) => !event.payload.groups.includes(group)), + }, + [leave(event.payload.channels, event.payload.groups)], + ), +); + +HeartbeatFailedState.on(reconnect.type, (context, _) => + HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }), +); + +HeartbeatFailedState.on(disconnect.type, (context, _) => + HeartbeatStoppedState.with( + { + channels: context.channels, + groups: context.groups, + }, + [leave(context.channels, context.groups)], + ), +); + +HeartbeatFailedState.on(leftAll.type, (context,_) => + HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]), +); diff --git a/src/event-engine/presence/states/heartbeat_inactive.ts b/src/event-engine/presence/states/heartbeat_inactive.ts index 44d9f1d02..b98a396c9 100644 --- a/src/event-engine/presence/states/heartbeat_inactive.ts +++ b/src/event-engine/presence/states/heartbeat_inactive.ts @@ -1,13 +1,15 @@ import { State } from '../../core/state'; import { Effects } from '../effects'; -import { Events, joined } from '../events'; +import { Events, joined, left } from '../events'; import { HeartbeatingState } from './heartbeating'; export const HeartbeatInactiveState = new State('HEARTBEAT_INACTIVE'); -HeartbeatInactiveState.on(joined.type, (context, event) => +HeartbeatInactiveState.on(joined.type, (_, event) => HeartbeatingState.with({ channels: event.payload.channels, groups: event.payload.groups, }), ); + +HeartbeatInactiveState.on(left.type, (_, event) => HeartbeatInactiveState.with()); diff --git a/src/event-engine/presence/states/heartbeat_reconnecting.ts b/src/event-engine/presence/states/heartbeat_reconnecting.ts index 8747194a1..2d64afeb6 100644 --- a/src/event-engine/presence/states/heartbeat_reconnecting.ts +++ b/src/event-engine/presence/states/heartbeat_reconnecting.ts @@ -1,12 +1,82 @@ import { State } from '../../core/state'; -import { Events } from '../events'; -import { Effects } from '../effects'; +import { PubNubError } from '../../../core/components/endpoint'; +import { + Events, + disconnect, + heartbeatFailure, + heartbeatGiveup, + heartbeatSuccess, + joined, + left, + leftAll, +} from '../events'; +import { Effects, delayedHeartbeat, leave } from '../effects'; +import { HeartbeatingState } from './heartbeating'; +import { HeartbeatStoppedState } from './heartbeat_stopped'; +import { HeartbeatCooldownState } from './heartbeat_cooldown'; +import { HeartbeatInactiveState } from './heartbeat_inactive'; +import { HeartbeatFailedState } from './heartbeat_failed'; export type HeartbeatReconnectingStateContext = { channels: string[]; groups: string[]; + + attempts: number; + reason: PubNubError; }; export const HearbeatReconnectingState = new State( 'HEARBEAT_RECONNECTING', ); + +HearbeatReconnectingState.onEnter((context) => delayedHeartbeat(context)); +HearbeatReconnectingState.onExit(() => delayedHeartbeat.cancel); + +HearbeatReconnectingState.on(joined.type, (context, event) => + HeartbeatingState.with({ + channels: [...context.channels, ...event.payload.channels], + groups: [...context.groups, ...event.payload.groups], + }), +); + +HearbeatReconnectingState.on(left.type, (context, event) => + HeartbeatingState.with( + { + channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), + groups: context.groups.filter((group) => !event.payload.groups.includes(group)), + }, + [leave(event.payload.channels, event.payload.groups)], + ), +); + +HearbeatReconnectingState.on(disconnect.type, (context, _) => { + HeartbeatStoppedState.with( + { + channels: context.channels, + groups: context.groups, + }, + [leave(context.channels, context.groups)], + ); +}); + +HearbeatReconnectingState.on(heartbeatSuccess.type, (context, _) => { + return HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups, + }); +}); + +HearbeatReconnectingState.on(heartbeatFailure.type, (context, event) => + HearbeatReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), +); + +HearbeatReconnectingState.on(heartbeatGiveup.type, (context, event) => { + return HeartbeatFailedState.with({ + channels: context.channels, + groups: context.groups, + }); +}); + +HearbeatReconnectingState.on(leftAll.type, (context, _) => + HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]), +); diff --git a/src/event-engine/presence/states/heartbeat_stopped.ts b/src/event-engine/presence/states/heartbeat_stopped.ts index e69de29bb..02e49579a 100644 --- a/src/event-engine/presence/states/heartbeat_stopped.ts +++ b/src/event-engine/presence/states/heartbeat_stopped.ts @@ -0,0 +1,50 @@ +import { State } from '../../core/state'; +import { Effects, leave } from '../effects'; +import { Events, joined, left, reconnect, leftAll, disconnect } from '../events'; +import { HeartbeatInactiveState } from './heartbeat_inactive'; +import { HeartbeatingState } from './heartbeating'; + +export type HeartbeatStoppedStateContext = { + channels: string[]; + groups: string[]; +}; + +export const HeartbeatStoppedState = new State('HEARTBEAT_STOPPED'); + +HeartbeatStoppedState.on(joined.type, (context, event) => + HeartbeatStoppedState.with({ + channels: [...context.channels, ...event.payload.channels], + groups: [...context.groups, ...event.payload.groups], + }), +); + +HeartbeatStoppedState.on(left.type, (context, event) => + HeartbeatStoppedState.with( + { + channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), + groups: context.groups.filter((group) => !event.payload.groups.includes(group)), + }, + [leave(event.payload.channels, event.payload.groups)], + ), +); + +HeartbeatStoppedState.on(reconnect.type, (context, _) => + HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }), +); + +HeartbeatStoppedState.on(disconnect.type, (context, _) => + HeartbeatStoppedState.with( + { + channels: context.channels, + groups: context.groups, + }, + [leave(context.channels, context.groups)], + ), +); + +HeartbeatStoppedState.on(leftAll.type, (context, _) => + HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]), +); diff --git a/src/event-engine/presence/states/heartbeating.ts b/src/event-engine/presence/states/heartbeating.ts index aa4d19999..cab28ed57 100644 --- a/src/event-engine/presence/states/heartbeating.ts +++ b/src/event-engine/presence/states/heartbeating.ts @@ -1,8 +1,10 @@ import { State } from '../../core/state'; -import { Events, heartbeatFailure, heartbeatSuccess, joined, left } from '../events'; +import { Events, disconnect, heartbeatFailure, heartbeatSuccess, joined, left, leftAll } from '../events'; import { Effects, heartbeat, leave } from '../effects'; import { HeartbeatCooldownState } from './heartbeat_cooldown'; import { HearbeatReconnectingState } from './heartbeat_reconnecting'; +import { HeartbeatStoppedState } from './heartbeat_stopped'; +import { HeartbeatInactiveState } from './heartbeat_inactive'; export type HeartbeatingStateContext = { channels: string[]; @@ -12,7 +14,6 @@ export type HeartbeatingStateContext = { export const HeartbeatingState = new State('HEARTBEATING'); HeartbeatingState.onEnter((context) => heartbeat(context.channels, context.groups)); -// HeartbeatingState.onExit(() => heartbeat.cancel); HeartbeatingState.on(heartbeatSuccess.type, (context, _) => { return HeartbeatCooldownState.with({ @@ -28,19 +29,34 @@ HeartbeatingState.on(joined.type, (context, event) => }), ); -HeartbeatingState.on(left.type, (context, event) => - HeartbeatingState.with( +HeartbeatingState.on(left.type, (context, event) => { + return HeartbeatingState.with( { channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), groups: context.groups.filter((group) => !event.payload.groups.includes(group)), }, [leave(event.payload.channels, event.payload.groups)], + ); +}); + +HeartbeatingState.on(heartbeatFailure.type, (context, event) => { + return HearbeatReconnectingState.with({ + ...context, + attempts: 0, + reason: event.payload, + }); +}); + +HeartbeatingState.on(disconnect.type, (context) => + HeartbeatStoppedState.with( + { + channels: context.channels, + groups: context.groups, + }, + [leave(context.channels, context.groups)], ), ); -HeartbeatingState.on(heartbeatFailure.type, (context, event) => - HearbeatReconnectingState.with({ - channels: context.channels, - groups: context.groups, - }), +HeartbeatingState.on(leftAll.type, (context, _) => + HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]), ); diff --git a/src/event-engine/states/handshake_failure.ts b/src/event-engine/states/handshake_failure.ts index 0f0fed581..0cb9a3069 100644 --- a/src/event-engine/states/handshake_failure.ts +++ b/src/event-engine/states/handshake_failure.ts @@ -1,6 +1,6 @@ import { State } from '../core/state'; -import { Effects, emitStatus } from '../effects'; -import { disconnect, Events, handshakingReconnectingRetry, reconnect } from '../events'; +import { Effects } from '../effects'; +import { disconnect, Events, reconnect } from '../events'; import { PubNubError } from '../../core/components/endpoint'; import { HandshakeReconnectingState } from './handshake_reconnecting'; import { HandshakeStoppedState } from './handshake_stopped'; @@ -15,15 +15,6 @@ export type HandshakeFailureStateContext = { export const HandshakeFailureState = new State('HANDSHAKE_FAILURE'); -HandshakeFailureState.onEnter((context) => emitStatus({ category: 'PNNetworkIssuesCategory' })); - -HandshakeFailureState.on(handshakingReconnectingRetry.type, (context) => - HandshakeReconnectingState.with({ - ...context, - attempts: 0, // TODO: figure out what should be the reason - }), -); - HandshakeFailureState.on(disconnect.type, (context) => HandshakeStoppedState.with({ channels: context.channels, diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index b6a426b09..efc7450f1 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -1,22 +1,27 @@ import { PubNubError } from '../../core/components/endpoint'; import { State } from '../core/state'; -import { Effects, emitEvents, handshakeReconnect, reconnect } from '../effects'; +import { Effects, emitEvents, emitStatus, handshakeReconnect, reconnect } from '../effects'; import { disconnect, Events, handshakingReconnectingFailure, handshakingReconnectingGiveup, handshakingReconnectingSuccess, + restore, subscriptionChange, + unsubscribeAll, } from '../events'; import { HandshakeFailureState } from './handshake_failure'; import { HandshakeStoppedState } from './handshake_stopped'; import { HandshakingState } from './handshaking'; import { ReceivingState } from './receiving'; +import { UnsubscribedState } from './unsubscribed'; +import categoryConstants from '../../core/constants/categories'; export type HandshakeReconnectingStateContext = { channels: string[]; groups: string[]; + timetoken?: string; attempts: number; reason: PubNubError; @@ -29,33 +34,51 @@ export const HandshakeReconnectingState = new State handshakeReconnect(context)); HandshakeReconnectingState.onExit(() => handshakeReconnect.cancel); -HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, (context, event) => - ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: event.payload.cursor, - }), -); +HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, (context, event) => { + const cursor = context.timetoken ? { timetoken: context.timetoken, region: 1 } : event.payload.cursor; + return ReceivingState.with( + { + channels: context.channels, + groups: context.groups, + cursor: cursor, + }, + [emitStatus({ category: categoryConstants.PNConnectedCategory })], + ); +}); HandshakeReconnectingState.on(handshakingReconnectingFailure.type, (context, event) => HandshakeReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), ); HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, (context) => - HandshakeFailureState.with({ - groups: context.groups, - channels: context.channels, - reason: context.reason, - }), + HandshakeFailureState.with( + { + groups: context.groups, + channels: context.channels, + reason: context.reason, + }, + [emitStatus({ category: categoryConstants.PNConnectionErrorCategory })], + ), ); HandshakeReconnectingState.on(disconnect.type, (context) => - HandshakeStoppedState.with({ - channels: context.channels, - groups: context.groups, - }), + HandshakeStoppedState.with( + { + channels: context.channels, + groups: context.groups, + }, + [emitStatus({ category: categoryConstants.PNDisconnectedCategory })], + ), ); HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), ); + +HandshakeReconnectingState.on(restore.type, (_, event) => + HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), +); + +HandshakeReconnectingState.on(unsubscribeAll.type, (_) => + UnsubscribedState.with(undefined, [emitStatus({ category: categoryConstants.PNDisconnectedCategory })]), +); diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index 483d214be..f414b7f06 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -8,7 +8,7 @@ type HandshakeStoppedStateContext = { groups: string[]; }; -export const HandshakeStoppedState = new State('STOPPED'); +export const HandshakeStoppedState = new State('HANDSHAKE_STOPPED'); HandshakeStoppedState.on(subscriptionChange.type, (_, event) => HandshakingState.with({ diff --git a/src/event-engine/states/handshaking.ts b/src/event-engine/states/handshaking.ts index 20bf7a400..68b0b733e 100644 --- a/src/event-engine/states/handshaking.ts +++ b/src/event-engine/states/handshaking.ts @@ -1,10 +1,19 @@ import { State } from '../core/state'; -import { Effects, handshake } from '../effects'; -import { disconnect, Events, handshakingFailure, handshakingSuccess, subscriptionChange } from '../events'; +import { Effects, handshake, emitStatus } from '../effects'; +import { + disconnect, + restore, + Events, + handshakingFailure, + handshakingSuccess, + subscriptionChange, + unsubscribeAll, +} from '../events'; import { HandshakeReconnectingState } from './handshake_reconnecting'; import { HandshakeStoppedState } from './handshake_stopped'; import { ReceivingState } from './receiving'; import { UnsubscribedState } from './unsubscribed'; +import categoryConstants from '../../core/constants/categories'; export type HandshakingStateContext = { channels: string[]; @@ -26,14 +35,17 @@ HandshakingState.on(subscriptionChange.type, (context, event) => { }); HandshakingState.on(handshakingSuccess.type, (context, event) => - ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: { - timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, - region: event.payload.region, + ReceivingState.with( + { + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + region: event.payload.region, + }, }, - }), + [emitStatus({ category: categoryConstants.PNConnectedCategory })], + ), ); HandshakingState.on(handshakingFailure.type, (context, event) => @@ -50,3 +62,13 @@ HandshakingState.on(disconnect.type, (context) => groups: context.groups, }), ); + +HandshakingState.on(unsubscribeAll.type, (_) => UnsubscribedState.with()); + +HandshakingState.on(restore.type, (_, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }), +); diff --git a/src/event-engine/states/receive_failure.ts b/src/event-engine/states/receive_failure.ts index 943650d9f..455966d1d 100644 --- a/src/event-engine/states/receive_failure.ts +++ b/src/event-engine/states/receive_failure.ts @@ -1,10 +1,12 @@ import { State } from '../core/state'; import { Cursor } from '../../models/Cursor'; -import { Effects } from '../effects'; -import { disconnect, Events, reconnectingRetry } from '../events'; -import { ReceiveReconnectingState } from './receive_reconnecting'; +import { Effects, emitStatus } from '../effects'; +import { disconnect, Events, reconnectingRetry, restore, subscriptionChange, unsubscribeAll } from '../events'; import { PubNubError } from '../../core/components/endpoint'; +import { HandshakingState } from './handshaking'; import { ReceiveStoppedState } from './receive_stopped'; +import categoryConstants from '../../core/constants/categories'; +import { UnsubscribedState } from './unsubscribed'; export type ReceiveFailureStateContext = { channels: string[]; @@ -14,12 +16,13 @@ export type ReceiveFailureStateContext = { reason: PubNubError; }; -export const ReceiveFailureState = new State('RECEIVE_FAILURE'); +export const ReceiveFailureState = new State('RECEIVE_FAILED'); ReceiveFailureState.on(reconnectingRetry.type, (context) => - ReceiveReconnectingState.with({ - ...context, - attempts: 0, // TODO: figure out what should be the reason + HandshakingState.with({ + channels: context.channels, + groups: context.groups, + timetoken: context.cursor.timetoken, }), ); @@ -30,3 +33,21 @@ ReceiveFailureState.on(disconnect.type, (context) => cursor: context.cursor, }), ); + +ReceiveFailureState.on(subscriptionChange.type, (_, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }), +); + +ReceiveFailureState.on(restore.type, (_, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }), +); + +ReceiveFailureState.on(unsubscribeAll.type, (_) => UnsubscribedState.with(undefined)); diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index b5668f515..47c379fd0 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -10,10 +10,13 @@ import { reconnectingSuccess, restore, subscriptionChange, + unsubscribeAll, } from '../events'; import { ReceivingState } from './receiving'; import { ReceiveFailureState } from './receive_failure'; import { ReceiveStoppedState } from './receive_stopped'; +import { UnsubscribedState } from './unsubscribed'; +import categoryConstants from '../../core/constants/categories'; export type ReceiveReconnectingStateContext = { channels: string[]; @@ -54,7 +57,7 @@ ReceiveReconnectingState.on(reconnectingGiveup.type, (context) => cursor: context.cursor, reason: context.reason, }, - [emitStatus({ category: 'PNDisconnectedCategory' })], + [emitStatus({ category: categoryConstants.PNDisconnectedUnexpectedlyCategory })], ), ); @@ -65,15 +68,18 @@ ReceiveReconnectingState.on(disconnect.type, (context) => groups: context.groups, cursor: context.cursor, }, - [emitStatus({ category: 'PNDisconnectedCategory' })], + [emitStatus({ category: categoryConstants.PNDisconnectedCategory })], ), ); -ReceiveReconnectingState.on(restore.type, (context) => +ReceiveReconnectingState.on(restore.type, (context, event) => ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken ?? context.cursor.timetoken, + region: event.payload.region ?? context.cursor.region, + }, }), ); @@ -84,3 +90,7 @@ ReceiveReconnectingState.on(subscriptionChange.type, (context, event) => cursor: context.cursor, }), ); + +ReceiveReconnectingState.on(unsubscribeAll.type, (_) => + UnsubscribedState.with(undefined, [emitStatus({ category: categoryConstants.PNDisconnectedCategory })]), +); diff --git a/src/event-engine/states/receive_stopped.ts b/src/event-engine/states/receive_stopped.ts index 6bca4abf9..cbb0396a8 100644 --- a/src/event-engine/states/receive_stopped.ts +++ b/src/event-engine/states/receive_stopped.ts @@ -1,8 +1,10 @@ import { Cursor } from '../../models/Cursor'; import { State } from '../core/state'; import { Effects } from '../effects'; -import { Events, reconnect, subscriptionChange } from '../events'; +import { Events, reconnect, restore, subscriptionChange, unsubscribeAll } from '../events'; +import { HandshakingState } from './handshaking'; import { ReceivingState } from './receiving'; +import { UnsubscribedState } from './unsubscribed'; type ReceiveStoppedStateContext = { channels: string[]; @@ -20,4 +22,19 @@ ReceiveStoppedState.on(subscriptionChange.type, (context, event) => }), ); -ReceiveStoppedState.on(reconnect.type, (context) => ReceivingState.with({ ...context })); +ReceiveStoppedState.on(restore.type, (context, event) => + ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }), +); + +ReceiveStoppedState.on(reconnect.type, (context) => + HandshakingState.with({ + channels: context.channels, + groups: context.groups, + }), +); + +ReceiveStoppedState.on(unsubscribeAll.type, () => UnsubscribedState.with(undefined)); diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index 5bb58e259..e3bed6e39 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -1,10 +1,11 @@ import { State } from '../core/state'; import { Cursor } from '../../models/Cursor'; import { Effects, emitEvents, emitStatus, receiveEvents } from '../effects'; -import { disconnect, Events, receivingFailure, receivingSuccess, subscriptionChange } from '../events'; +import { disconnect, Events, receivingFailure, receivingSuccess, subscriptionChange, unsubscribeAll } from '../events'; import { UnsubscribedState } from './unsubscribed'; import { ReceiveReconnectingState } from './receive_reconnecting'; import { ReceiveStoppedState } from './receive_stopped'; +import categoryConstants from '../../core/constants/categories'; export type ReceivingStateContext = { channels: string[]; @@ -14,12 +15,13 @@ export type ReceivingStateContext = { export const ReceivingState = new State('RECEIVING'); -ReceivingState.onEnter((_) => emitStatus({ category: 'PNConnectedCategory' })); ReceivingState.onEnter((context) => receiveEvents(context.channels, context.groups, context.cursor)); ReceivingState.onExit(() => receiveEvents.cancel); ReceivingState.on(receivingSuccess.type, (context, event) => { - return ReceivingState.with({ ...context, cursor: event.payload.cursor }, [emitEvents(event.payload.events)]); + return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor }, [ + emitEvents(event.payload.events), + ]); }); ReceivingState.on(subscriptionChange.type, (context, event) => { @@ -27,7 +29,11 @@ ReceivingState.on(subscriptionChange.type, (context, event) => { return UnsubscribedState.with(undefined); } - return ReceivingState.with({ ...context, channels: event.payload.channels, groups: event.payload.groups }); + return ReceivingState.with({ + cursor: context.cursor, + channels: event.payload.channels, + groups: event.payload.groups, + }); }); ReceivingState.on(receivingFailure.type, (context, event) => { @@ -45,6 +51,10 @@ ReceivingState.on(disconnect.type, (context) => { groups: context.groups, cursor: context.cursor, }, - [emitStatus({ category: 'PNDisconnectedCategory' })], + [emitStatus({ category: categoryConstants.PNDisconnectedCategory })], ); }); + +ReceivingState.on(unsubscribeAll.type, (_) => + UnsubscribedState.with(undefined, [emitStatus({ category: categoryConstants.PNDisconnectedCategory })]), +); diff --git a/src/event-engine/states/unsubscribed.ts b/src/event-engine/states/unsubscribed.ts index bebc046d9..b72e1dfe6 100644 --- a/src/event-engine/states/unsubscribed.ts +++ b/src/event-engine/states/unsubscribed.ts @@ -1,6 +1,6 @@ import { State } from '../core/state'; import { Effects } from '../effects'; -import { Events, subscriptionChange } from '../events'; +import { Events, subscriptionChange, restore } from '../events'; import { HandshakingState } from './handshaking'; export const UnsubscribedState = new State('UNSUBSCRIBED'); @@ -12,3 +12,11 @@ UnsubscribedState.on(subscriptionChange.type, (_, event) => timetoken: event.payload.timetoken, }), ); + +UnsubscribedState.on(restore.type, (_, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }), +); From ae980764e31e0ae082f3838da8eb4d83faf33970 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:26:09 +0530 Subject: [PATCH 22/63] event engine effects and events --- src/event-engine/dispatcher.ts | 138 +++++++++++++----------- src/event-engine/events.ts | 10 +- src/event-engine/presence/dispatcher.ts | 69 ++++++++---- src/event-engine/presence/effects.ts | 8 +- src/event-engine/presence/events.ts | 9 +- 5 files changed, 138 insertions(+), 96 deletions(-) diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index f723ce2de..2b26aae5f 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -6,9 +6,12 @@ import * as events from './events'; export type Dependencies = { handshake: any; receiveEvents: any; + join: any; + leave: any; + leaveAll: any; + presenceState: any; + config: any; - getRetryDelay: (attempts: number) => number; - shouldRetry: (error: Error, attempts: number) => boolean; delay: (milliseconds: number) => Promise; emitEvents: (events: any[]) => void; @@ -21,7 +24,7 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, abortSignal, { handshake, presenceState, config }) => { abortSignal.throwIfAborted(); try { @@ -29,9 +32,11 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, abortSignal, { receiveEvents, config }) => { abortSignal.throwIfAborted(); - try { const result = await receiveEvents({ abortSignal: abortSignal, @@ -56,6 +60,7 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, _, { emitEvents }) => { if (payload.length > 0) { emitEvents(payload); } @@ -82,77 +87,82 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, _, { emitStatus }) => { emitStatus(payload); }), ); this.on( effects.reconnect.type, - asyncHandler(async (payload, abortSignal, { receiveEvents, shouldRetry, getRetryDelay, delay }) => { - if (!shouldRetry(payload.reason, payload.attempts)) { - return engine.transition(events.reconnectingGiveup()); - } - - abortSignal.throwIfAborted(); - - await delay(getRetryDelay(payload.attempts)); - - abortSignal.throwIfAborted(); - - try { - const result = await receiveEvents({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - timetoken: payload.cursor.timetoken, - region: payload.cursor.region, - }); - - return engine.transition(events.reconnectingSuccess(result.metadata, result.messages)); - } catch (error) { - if (error instanceof Error && error.message === 'Aborted') { - return; - } - - if (error instanceof PubNubError) { - return engine.transition(events.reconnectingFailure(error)); + asyncHandler(async (payload, abortSignal, { receiveEvents, delay, config }) => { + if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) { + abortSignal.throwIfAborted(); + + await delay(config.retryConfiguration.getDelay(payload.attempts)); + + abortSignal.throwIfAborted(); + + try { + const result = await receiveEvents({ + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + timetoken: payload.cursor.timetoken, + region: payload.cursor.region, + filterExpression: config.filterExpression, + }); + + return engine.transition(events.reconnectingSuccess(result.metadata, result.messages)); + } catch (error) { + if (error instanceof Error && error.message === 'Aborted') { + return; + } + + if (error instanceof PubNubError) { + return engine.transition(events.reconnectingFailure(error)); + } } + } else { + return engine.transition(events.reconnectingGiveup()); } }), ); this.on( effects.handshakeReconnect.type, - asyncHandler(async (payload, abortSignal, { handshake, shouldRetry, getRetryDelay, delay }) => { - if (!shouldRetry(payload.reason, payload.attempts)) { - return engine.transition(events.handshakingReconnectingGiveup()); - } - - abortSignal.throwIfAborted(); - - await delay(getRetryDelay(payload.attempts)); - - abortSignal.throwIfAborted(); - - try { - const result = await handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - }); - - return engine.transition(events.handshakingReconnectingSuccess(result)); - } catch (error) { - if (error instanceof Error && error.message === 'Aborted') { - return; - } - - if (error instanceof PubNubError) { - return engine.transition(events.handshakingReconnectingFailure(error)); + asyncHandler( + async (payload, abortSignal, { handshake, delay, presenceState, config }) => { + if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) { + abortSignal.throwIfAborted(); + + await delay(config.retryConfiguration.getDelay(payload.attempts)); + + abortSignal.throwIfAborted(); + + try { + const result = await handshake({ + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + filterExpression: config.filterExpression, + state: presenceState, + }); + + return engine.transition(events.handshakingReconnectingSuccess(result)); + } catch (error) { + if (error instanceof Error && error.message === 'Aborted') { + return; + } + + if (error instanceof PubNubError) { + return engine.transition(events.handshakingReconnectingFailure(error)); + } + } + } else { + return engine.transition(events.handshakingReconnectingGiveup()); } - } - }), + }, + ), ); } } diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 45a52974b..21e91aff2 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -14,7 +14,7 @@ export const subscriptionChange = createEvent( export const disconnect = createEvent('DISCONNECT', () => ({})); export const reconnect = createEvent('RECONNECT', () => ({})); export const restore = createEvent( - 'RESTORE', + 'SUBSCRIPTION_RESTORED', (channels: string[], groups: string[], timetoken?: string, region?: number) => ({ channels, groups, @@ -31,7 +31,6 @@ export const handshakingReconnectingSuccess = createEvent('HANDSHAKE_RECONNECT_S })); export const handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', (error: PubNubError) => error); export const handshakingReconnectingGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', () => ({})); -export const handshakingReconnectingRetry = createEvent('HANDSHAKING_RECONNECTING_RETRY', () => ({})); export const receivingSuccess = createEvent('RECEIVE_SUCCESS', (cursor: Cursor, events: any[]) => ({ cursor, @@ -43,13 +42,15 @@ export const reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', (cur cursor, events, })); -export const reconnectingFailure = createEvent('RECEIVING_RECONNECTING_FAILURE', (error: PubNubError) => error); +export const reconnectingFailure = createEvent('RECEIVE_RECONNECT_FAILURE', (error: PubNubError) => error); export const reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', () => ({})); -export const reconnectingRetry = createEvent('RECEIVING_RECONNECTING_RETRY', () => ({})); +export const reconnectingRetry = createEvent('RECONNECT', () => ({})); +export const unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', () => {}); export type Events = MapOf< | typeof subscriptionChange | typeof disconnect + | typeof unsubscribeAll | typeof reconnect | typeof restore | typeof handshakingSuccess @@ -57,7 +58,6 @@ export type Events = MapOf< | typeof handshakingReconnectingSuccess | typeof handshakingReconnectingGiveup | typeof handshakingReconnectingFailure - | typeof handshakingReconnectingRetry | typeof receivingSuccess | typeof receivingFailure | typeof reconnectingSuccess diff --git a/src/event-engine/presence/dispatcher.ts b/src/event-engine/presence/dispatcher.ts index 9fd305f27..910a092dc 100644 --- a/src/event-engine/presence/dispatcher.ts +++ b/src/event-engine/presence/dispatcher.ts @@ -6,24 +6,25 @@ import * as events from './events'; export type Dependencies = { heartbeat: any; leave: any; - heartbeatDelay: (millisecond: number) => Promise; - getDelayTime: () => number; // gets value from configuration + heartbeatDelay: () => Promise; + + retryDelay: (milliseconds: number) => Promise; + config: any; + presenceState: any; }; export class PresenceEventEngineDispatcher extends Dispatcher { - /** - * Effect Dispatcher for presence events - */ constructor(engine: Engine, dependencies: Dependencies) { super(dependencies); this.on( effects.heartbeat.type, - asyncHandler(async (payload, _, { heartbeat }) => { + asyncHandler(async (payload, _, { heartbeat, presenceState }) => { try { const result = await heartbeat({ channels: payload.channels, channelGroups: payload.groups, + state: presenceState, }); engine.transition(events.heartbeatSuccess()); @@ -37,32 +38,58 @@ export class PresenceEventEngineDispatcher extends Dispatcher { - try { - const result = await leave({ - channels: payload.channels, - channelGroups: payload.groups, - }); - - // engine.transition(events.leaveSuccess()); - } catch (e) { - if (e instanceof PubNubError) { - // return engine.transition(events.leaveFailure(e)); - } + asyncHandler(async (payload, _, { leave, config }) => { + if (!config.suppressLeaveEvents) { + try { + const result = await leave({ + channels: payload.channels, + channelGroups: payload.groups, + }); + } catch (e) {} } }), ); this.on( effects.wait.type, - asyncHandler(async (_, abortSignal, { heartbeatDelay, getDelayTime }) => { + asyncHandler(async (_, abortSignal, { heartbeatDelay }) => { abortSignal.throwIfAborted(); - await heartbeatDelay(getDelayTime()); + await heartbeatDelay(); abortSignal.throwIfAborted(); - return engine.transition(events.leaveSuccess()); + return engine.transition(events.timesUp()); + }), + ); + + this.on( + effects.delayedHeartbeat.type, + asyncHandler(async (payload, abortSignal, { heartbeat, retryDelay, presenceState, config }) => { + if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) { + abortSignal.throwIfAborted(); + await retryDelay(config.retryConfiguration.getDelay(payload.attempts)); + abortSignal.throwIfAborted(); + try { + const result = await heartbeat({ + channels: payload.channels, + channelGroups: payload.groups, + state: presenceState, + }); + console.log(`after hb call`); + return engine.transition(events.heartbeatSuccess()); + } catch (e) { + if (e instanceof Error && e.message === 'Aborted') { + return; + } + + if (e instanceof PubNubError) { + return engine.transition(events.heartbeatFailure(e)); + } + } + } else { + return engine.transition(events.heartbeatGiveup()); + } }), ); } diff --git a/src/event-engine/presence/effects.ts b/src/event-engine/presence/effects.ts index 06c8b285e..efbd786f2 100644 --- a/src/event-engine/presence/effects.ts +++ b/src/event-engine/presence/effects.ts @@ -1,4 +1,5 @@ import { createEffect, createManagedEffect, MapOf } from '../core'; +import { HeartbeatReconnectingStateContext } from './states/heartbeat_reconnecting'; export const heartbeat = createEffect('HEARTBEAT', (channels: string[], groups: string[]) => ({ channels, @@ -12,4 +13,9 @@ export const leave = createEffect('LEAVE', (channels: string[], groups: string[] export const wait = createManagedEffect('WAIT', () => ({})); -export type Effects = MapOf; +export const delayedHeartbeat = createManagedEffect( + 'DELAYED_HEARTBEAT', + (context: HeartbeatReconnectingStateContext) => context, +); + +export type Effects = MapOf; diff --git a/src/event-engine/presence/events.ts b/src/event-engine/presence/events.ts index 8bf539dd9..4dc50e448 100644 --- a/src/event-engine/presence/events.ts +++ b/src/event-engine/presence/events.ts @@ -1,6 +1,7 @@ import { PubNubError } from '../../core/components/endpoint'; import { createEvent, MapOf } from '../core'; +export const reconnect = createEvent('RECONNECT', () => ({})); export const disconnect = createEvent('DISCONNECT', () => ({})); export const joined = createEvent('JOINED', (channels: string[], groups: string[]) => ({ @@ -19,19 +20,17 @@ export const heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', () => ({})); export const heartbeatFailure = createEvent('HEARTBEAT_FAILURE', (error: PubNubError) => error); -export const leaveSuccess = createEvent('LEAVE_SUCCESS', () => ({})); - -export const leaveFailure = createEvent('LEAVE_FAILURE', (error: PubNubError) => error); +export const heartbeatGiveup = createEvent('HEARTBEAT_GIVEUP', () => ({})); export const timesUp = createEvent('TIMES_UP', () => ({})); export type Events = MapOf< + | typeof reconnect | typeof disconnect | typeof leftAll | typeof heartbeatSuccess | typeof heartbeatFailure - | typeof leaveSuccess - | typeof leaveFailure + | typeof heartbeatGiveup | typeof joined | typeof left | typeof timesUp From e1e02ccd8b83023db751b312862edc7b76fa31a4 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:26:38 +0530 Subject: [PATCH 23/63] retry policy configuration --- src/event-engine/core/reconnectionDelay.ts | 13 ------ src/event-engine/core/retryPolicy.ts | 52 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 13 deletions(-) delete mode 100644 src/event-engine/core/reconnectionDelay.ts create mode 100644 src/event-engine/core/retryPolicy.ts diff --git a/src/event-engine/core/reconnectionDelay.ts b/src/event-engine/core/reconnectionDelay.ts deleted file mode 100644 index 3c34bddcf..000000000 --- a/src/event-engine/core/reconnectionDelay.ts +++ /dev/null @@ -1,13 +0,0 @@ -export class ReconnectionDelay { - static getDelay(policy: string, attempts: number, backoff?: number): number { - const backoffValue = backoff ?? 5; - switch (policy.toUpperCase()) { - case 'LINEAR': - return attempts * backoffValue + Math.random() * 1000; - case 'EXPONENTIAL': - return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; - default: - throw new Error('invalid policy'); - } - } -} diff --git a/src/event-engine/core/retryPolicy.ts b/src/event-engine/core/retryPolicy.ts new file mode 100644 index 000000000..0677e1b92 --- /dev/null +++ b/src/event-engine/core/retryPolicy.ts @@ -0,0 +1,52 @@ +export class RetryPolicy { + static LinearRetryPolicy(configuration: LinearRetryPolicyConfiguration) { + return { + delay: configuration.delay, + maximumRetry: configuration.maximumRetry, + shouldRetry(error: any, attempt: number) { + if (error?.status?.statusCode === 403) { + return false; + } + return this.maximumRetry > attempt; + }, + getDelay(_: number) { + return this.delay * 1000; + }, + }; + } + + static ExponentialRetryPolicy(configuration: ExponentialRetryPolicyConfiguration) { + return { + minimumDelay: configuration.minimumDelay, + maximumDelay: configuration.maximumDelay, + maximumRetry: configuration.maximumRetry, + + shouldRetry(error: any, attempt: number) { + if (error?.status?.statusCode === 403) { + return false; + } + return this.maximumRetry > attempt; + }, + + getDelay(attempt: number) { + const calculatedDelay = Math.trunc(Math.pow(2, attempt)) * 1000 + Math.random() * 1000; + if (calculatedDelay > 150000) { + return 150000; + } else { + return calculatedDelay; + } + }, + }; + } +} + +export type LinearRetryPolicyConfiguration = { + delay: number; + maximumRetry: number; +}; + +export type ExponentialRetryPolicyConfiguration = { + minimumDelay: number; + maximumDelay: number; + maximumRetry: number; +}; From 85dc261ea551eaf0739bf71b0d69d4853408094a Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:27:18 +0530 Subject: [PATCH 24/63] event engines tests --- src/event-engine/index.ts | 63 ++++++++- src/event-engine/presence/presence.ts | 43 +++++- test/contract/definitions/event-engine.ts | 153 +++++++++++++++++++++- test/contract/shared/pubnub.ts | 14 +- test/unit/event_engine.test.ts | 2 +- test/unit/event_engine_presence.test.ts | 127 ++++++++++++++++++ 6 files changed, 385 insertions(+), 17 deletions(-) create mode 100644 test/unit/event_engine_presence.test.ts diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index 4bb15948a..02f86914c 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -8,6 +8,7 @@ import { UnsubscribedState } from './states/unsubscribed'; export class EventEngine { private engine: Engine = new Engine(); private dispatcher: Dispatcher; + private dependencies: any; get _engine() { return this.engine; @@ -16,6 +17,7 @@ export class EventEngine { private _unsubscribeEngine!: () => void; constructor(dependencies: Dependencies) { + this.dependencies = dependencies; this.dispatcher = new EventEngineDispatcher(this.engine, dependencies); this._unsubscribeEngine = this.engine.subscribe((change) => { @@ -30,25 +32,69 @@ export class EventEngine { channels: string[] = []; groups: string[] = []; - subscribe({ channels, groups, timetoken }: { channels?: string[]; groups?: string[]; timetoken?: string }) { + subscribe({ + channels, + channelGroups, + timetoken, + withPresence, + }: { + channels?: string[]; + channelGroups?: string[]; + timetoken?: string; + withPresence?: boolean; + }) { this.channels = [...this.channels, ...(channels ?? [])]; - this.groups = [...this.groups, ...(groups ?? [])]; - - this.engine.transition(events.subscriptionChange(this.channels, this.groups, timetoken ?? '0')); + this.groups = [...this.groups, ...(channelGroups ?? [])]; + if (withPresence) { + this.channels.map((c) => this.channels.push(`${c}-pnpres`)); + this.groups.map((g) => this.groups.push(`${g}-pnpres`)); + } + if (timetoken) { + this.engine.transition(events.restore(this.channels, this.groups, timetoken)); + } else { + this.engine.transition(events.subscriptionChange(this.channels, this.groups)); + } + if (this.dependencies.join) { + this.dependencies.join({ + channels: this.channels.filter((c) => !c.endsWith('-pnpres')), + groups: this.groups.filter((g) => !g.endsWith('-pnpres')), + }); + } } unsubscribe({ channels, groups }: { channels?: string[]; groups?: string[] }) { - this.channels = this.channels.filter((channel) => !channels?.includes(channel) ?? true); - this.groups = this.groups.filter((group) => !groups?.includes(group) ?? true); - + let channlesWithPres: any = channels?.slice(0); + channels?.map((c) => channlesWithPres.push(`${c}-pnpres`)); + this.channels = this.channels.filter((channel) => !channlesWithPres?.includes(channel)); + + let groupsWithPres: any = groups?.slice(0); + groups?.map((g) => groupsWithPres.push(`${g}-pnpres`)); + this.groups = this.groups.filter((group) => !groupsWithPres?.includes(group)); + + if (this.dependencies.presenceState) { + channels?.forEach((c) => delete this.dependencies.presenceState[c]); + groups?.forEach((g) => delete this.dependencies.presenceState[g]); + } this.engine.transition(events.subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + if (this.dependencies.leave) { + this.dependencies.leave({ + channels: channels, + groups: groups, + }); + } } unsubscribeAll() { this.channels = []; this.groups = []; + if (this.dependencies.presenceState) { + this.dependencies.presenceState = {}; + } this.engine.transition(events.subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + if (this.dependencies.leaveAll) { + this.dependencies.leaveAll(); + } } reconnect() { @@ -57,6 +103,9 @@ export class EventEngine { disconnect() { this.engine.transition(events.disconnect()); + if (this.dependencies.leaveAll) { + this.dependencies.leaveAll(); + } } dispose() { diff --git a/src/event-engine/presence/presence.ts b/src/event-engine/presence/presence.ts index cb47a05ea..05cb03500 100644 --- a/src/event-engine/presence/presence.ts +++ b/src/event-engine/presence/presence.ts @@ -3,18 +3,55 @@ import * as events from './events'; import * as effects from './effects'; import { Dependencies, PresenceEventEngineDispatcher } from './dispatcher'; +import { HeartbeatInactiveState } from './states/heartbeat_inactive'; + export class PresenceEventEngine { private engine: Engine = new Engine(); private dispatcher: Dispatcher; + private dependencies: any; get _engine() { return this.engine; } - /** - * - */ + private _unsubscribeEngine!: () => void; + constructor(dependencies: Dependencies) { this.dispatcher = new PresenceEventEngineDispatcher(this.engine, dependencies); + this.dependencies = dependencies; + + this._unsubscribeEngine = this.engine.subscribe((change) => { + if (change.type === 'invocationDispatched') { + this.dispatcher.dispatch(change.invocation); + } + }); + + this.engine.start(HeartbeatInactiveState, undefined); + } + channels: string[] = []; + groups: string[] = []; + + join({ channels, groups }: { channels?: string[]; groups?: string[] }) { + this.channels = [...this.channels, ...(channels ?? [])]; + this.groups = [...this.groups, ...(groups ?? [])]; + + this.engine.transition(events.joined(this.channels.slice(0), this.groups.slice(0))); + } + + leave({ channels, groups }: { channels?: string[]; groups?: string[] }) { + if (this.dependencies.presenceState) { + channels?.forEach((c) => delete this.dependencies.presenceState[c]); + groups?.forEach((g) => delete this.dependencies.presenceState[g]); + } + this.engine.transition(events.left(channels ?? [], groups ?? [])); + } + + leaveAll() { + this.engine.transition(events.leftAll()); + } + + dispose() { + this._unsubscribeEngine(); + this.dispatcher.dispose(); } } diff --git a/test/contract/definitions/event-engine.ts b/test/contract/definitions/event-engine.ts index 8d5c8f5db..f64985165 100644 --- a/test/contract/definitions/event-engine.ts +++ b/test/contract/definitions/event-engine.ts @@ -5,6 +5,7 @@ import type { MessageEvent, StatusEvent } from 'pubnub'; import type { Change } from '../../../src/event-engine/core/change'; import { DataTable } from '@cucumber/cucumber'; import { expect } from 'chai'; +import PubNubClass from '../../../lib/node/index.js'; function logChangelog(changelog: Change) { switch (changelog.type) { @@ -32,26 +33,136 @@ class EventEngineSteps { private messagePromise?: Promise; private statusPromise?: Promise; private changelog: Change[] = []; + private configuration: any = {}; constructor(private manager: PubNubManager, private keyset: DemoKeyset) {} + private async testDelay(time: number) { + return new Promise((resolve) => setTimeout(resolve, time * 1000)); + } + @given('the demo keyset with event engine enabled') givenDemoKeyset() { - this.pubnub = this.manager.getInstance({ ...this.keyset, enableSubscribeBeta: true }); + this.pubnub = this.manager.getInstance({ ...this.keyset, enableEventEngine: true }); (this.pubnub as any).eventEngine._engine.subscribe((changelog: Change) => { - // logChangelog(changelog); if (changelog.type === 'eventReceived' || changelog.type === 'invocationDispatched') { this.changelog.push(changelog); } }); } + @given('the demo keyset with Presence EE enabled') + givenPresenceEEDemoKeyset() { + this.configuration.enableEventEngine = true; + } + + @when('heartbeatInterval set to {string}, timeout set to {string} and suppressLeaveEvents set to {string}') + whenPresenceConfiguration(heartbeatInterval: string, presenceTimeout: string, suppressLeaveEvents: string) { + this.configuration.heartbeatInterval = +heartbeatInterval; + this.configuration.presenceTimeout = +presenceTimeout; + this.configuration.suppressLeaveEvents = suppressLeaveEvents === 'true'; + } + + @when('I join {string}, {string}, {string} channels') + whenJoinChannels(channelOne: string, channelTwo: string, channelThree: string) { + this.pubnub = this.manager.getInstance({ ...this.keyset, ...this.configuration }); + (this.pubnub as any).presenceEventEngine?._engine.subscribe((changelog: Change) => { + if (changelog.type === 'eventReceived' || changelog.type === 'invocationDispatched') { + this.changelog.push(changelog); + } + }); + this.pubnub?.subscribe({ channels: [channelOne, channelTwo, channelThree] }); + } + + @when('I join {string}, {string}, {string} channels with presence') + whenJoinChannelsWithPresence(channelOne: string, channelTwo: string, channelThree: string) { + this.pubnub = this.manager.getInstance({ ...this.keyset, ...this.configuration }); + (this.pubnub as any)?.presenceEventEngine?._engine.subscribe((changelog: Change) => { + if (changelog.type === 'eventReceived' || changelog.type === 'invocationDispatched') { + this.changelog.push(changelog); + } + }); + + this.statusPromise = new Promise((resolveStatus) => { + this.messagePromise = new Promise((resolveMessage) => { + this.pubnub?.addListener({ + message(messageEvent) { + resolveMessage(messageEvent); + }, + status(statusEvent) { + resolveStatus(statusEvent); + }, + }); + + this.pubnub?.subscribe({ channels: [channelOne, channelTwo, channelThree], withPresence: true }); + }); + }); + } + + @then('I wait for getting Presence joined events') + async thenPresenceJoinEvent() { + const status = await this.messagePromise; + } + + @then('I wait {string} seconds') + async thenWait(seconds: string) { + await this.testDelay(+seconds); + } + + @then('I observe the following Events and Invocations of the Presence EE:') + async thenIObservePresenceEE(dataTable: DataTable) { + const expectedChangelog = dataTable.hashes(); + const actualChangelog = []; + for (const entry of this.changelog) { + if (entry.type === 'eventReceived') { + actualChangelog.push({ type: 'event', name: entry.event.type }); + } else if (entry.type === 'invocationDispatched') { + actualChangelog.push({ + type: 'invocation', + name: `${entry.invocation.type}${entry.invocation.type === 'CANCEL' ? `_${entry.invocation.payload}` : ''}`, + }); + } + } + + expect(actualChangelog).to.deep.equal(expectedChangelog); + } + + @then('I leave {string} and {string} channels with presence') + async theILeave(channelOne: string, channelTwo: string) { + await this.testDelay(0.02); + this.pubnub?.unsubscribe({ channels: [channelOne, channelTwo] }); + } + @given('a linear reconnection policy with {int} retries') givenLinearReconnectionPolicy(retries: number) { - // TODO + // @ts-ignore + this.configuration.retryConfiguration = PubNubClass.LinearRetryPolicy({ + delay: 2, + maximumRetry: retries, + }); + // @ts-ignore + this.pubnub = this.manager.getInstance({ + ...this.keyset, + enableEventEngine: true, + // @ts-ignore + retryConfiguration: PubNubClass.LinearRetryPolicy({ + delay: 2, + maximumRetry: retries, + }), + }); + + (this.pubnub as any).eventEngine._engine.subscribe((changelog: Change) => { + if (changelog.type === 'eventReceived' || changelog.type === 'invocationDispatched') { + this.changelog.push(changelog); + } + }); } + @then('I receive an error in my heartbeat response', undefined, 10000) + async thenHeartbeatError() { + await this.testDelay(9); + } @when('I subscribe') async whenISubscribe() { this.statusPromise = new Promise((resolveStatus) => { @@ -70,6 +181,24 @@ class EventEngineSteps { }); } + @when('I subscribe with timetoken {int}') + async whenISubscribeWithTimetoken(timetoken: number) { + this.statusPromise = new Promise((resolveStatus) => { + this.messagePromise = new Promise((resolveMessage) => { + this.pubnub?.addListener({ + message(messageEvent) { + resolveMessage(messageEvent); + }, + status(statusEvent) { + resolveStatus(statusEvent); + }, + }); + + this.pubnub?.subscribe({ channels: ['test'], timetoken: timetoken }); + }); + }); + } + @when('I publish a message') async whenIPublishAMessage() { const status = await this.statusPromise; @@ -83,7 +212,7 @@ class EventEngineSteps { async thenIReceiveError() { const status = await this.statusPromise; - expect(status?.category).to.equal('PNNetworkIssuesCategory'); + expect(status?.category).to.equal('PNConnectionErrorCategory'); } @then('I receive the message in my subscribe response') @@ -110,6 +239,22 @@ class EventEngineSteps { expect(actualChangelog).to.deep.equal(expectedChangelog); } + @then("I don't observe any Events and Invocations of the Presence EE") + noeventInvocations() { + const actualChangelog = []; + for (const entry of this.changelog) { + if (entry.type === 'eventReceived') { + actualChangelog.push({ type: 'event', name: entry.event.type }); + } else if (entry.type === 'invocationDispatched') { + actualChangelog.push({ + type: 'invocation', + name: `${entry.invocation.type}${entry.invocation.type === 'CANCEL' ? `_${entry.invocation.payload}` : ''}`, + }); + } + } + expect(actualChangelog).to.deep.equal([]); + } + @after() dispose() { (this.pubnub as any).removeAllListeners(); diff --git a/test/contract/shared/pubnub.ts b/test/contract/shared/pubnub.ts index 0823e9d5a..d8d46ad8e 100644 --- a/test/contract/shared/pubnub.ts +++ b/test/contract/shared/pubnub.ts @@ -6,19 +6,29 @@ export interface Keyset { publishKey?: string; } +export interface RetryConfiguration { + delay?: number; + maximumRetry?: number; + shouldRetry: any; + getDelay: any; +} + export interface Config extends Keyset { origin?: string; ssl?: boolean; suppressLeaveEvents?: boolean; logVerbosity?: boolean; uuid?: string; - enableSubscribeBeta?: boolean; + enableEventEngine?: boolean; + retryConfiguration?: RetryConfiguration; + heartbeatInterval?: number; + presenceTimeout?: number; } const defaultConfig: Config = { origin: 'localhost:8090', ssl: false, - suppressLeaveEvents: true, + suppressLeaveEvents: false, logVerbosity: false, uuid: 'myUUID', }; diff --git a/test/unit/event_engine.test.ts b/test/unit/event_engine.test.ts index de3b868c0..b45db4dc6 100644 --- a/test/unit/event_engine.test.ts +++ b/test/unit/event_engine.test.ts @@ -22,7 +22,7 @@ describe('EventEngine', () => { subscribeKey: 'demo', publishKey: 'demo', uuid: 'test-js', - enableSubscribeBeta: true, + enableEventEngine: true, }); engine = pubnub.eventEngine._engine; diff --git a/test/unit/event_engine_presence.test.ts b/test/unit/event_engine_presence.test.ts new file mode 100644 index 000000000..894f69c51 --- /dev/null +++ b/test/unit/event_engine_presence.test.ts @@ -0,0 +1,127 @@ +import nock from 'nock'; +import utils from '../utils'; +import PubNub from '../../src/node/index'; + +describe('EventEngine', () => { + let pubnub: PubNub; + let engine: PubNub['presenceEventEngine']['engine']; + + before(() => { + nock.disableNetConnect(); + }); + + after(() => { + nock.enableNetConnect(); + }); + + let unsub; + beforeEach(() => { + nock.cleanAll(); + + pubnub = new PubNub({ + subscribeKey: 'demo', + publishKey: 'demo', + uuid: 'test-js', + enableEventEngine: true, + heartbeatInterval: 1, + logVerbosity: true, + }); + + engine = pubnub.presenceEventEngine._engine; + + unsub = engine.subscribe((change) => { + console.log(change); + }); + }); + + afterEach(() => { + unsub(); + }); + + function forEvent(eventLabel: string, timeout?: number) { + return new Promise((resolve, reject) => { + let timeoutId = null; + + const unsubscribe = engine.subscribe((change) => { + if (change.type === 'eventReceived' && change.event.type === eventLabel) { + if (timeoutId) clearTimeout(timeoutId); + unsubscribe(); + resolve(); + } + }); + + if (timeout) { + timeoutId = setTimeout(() => { + unsubscribe(); + reject(new Error(`Timeout occured while waiting for event ${eventLabel}`)); + }, timeout); + } + }); + } + + function forState(stateLabel: string, timeout?: number) { + return new Promise((resolve, reject) => { + let timeoutId = null; + + const unsubscribe = engine.subscribe((change) => { + if (change.type === 'transitionDone' && change.toState.label === stateLabel) { + if (timeoutId) clearTimeout(timeoutId); + unsubscribe(); + resolve(); + } + }); + + if (timeout) { + timeoutId = setTimeout(() => { + unsubscribe(); + reject(new Error(`Timeout occured while waiting for state ${stateLabel}`)); + }, timeout); + } + }); + } + + function forInvocation(invocationLabel: string, timeout?: number) { + return new Promise((resolve, reject) => { + let timeoutId = null; + + const unsubscribe = engine.subscribe((change) => { + if (change.type === 'invocationDispatched' && change.invocation.type === invocationLabel) { + if (timeoutId) clearTimeout(timeoutId); + unsubscribe(); + resolve(); + } + }); + + if (timeout) { + timeoutId = setTimeout(() => { + unsubscribe(); + reject(new Error(`Timeout occured while waiting for invocation ${invocationLabel}`)); + }, timeout); + } + }); + } + + it(' presence event_engine should work correctly', async () => { + utils + .createNock() + .get('/v2/presence/sub-key/demo/channel/test/heartbeat') + .query(true) + .reply(200, '{"message":"OK", "service":"Presence"}'); + + pubnub.join({ channels: ['test'] }); + + await forEvent('JOINED', 1000); + + await forState('HEARTBEATING', 1000); + + await forEvent('HEARTBEAT_SUCCESS', 1000); + + await forState('HEARTBEATCOOLDOWN', 1000); + + pubnub.leaveAll(); + + await forEvent('LEFT_ALL', 2000); + + }); + +}); From 69ce9485c229a4bc2355b9b10646c9604603158f Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:27:57 +0530 Subject: [PATCH 25/63] updated stateless utilities --- src/core/endpoints/presence/heartbeat.js | 6 ++++-- src/core/endpoints/presence/set_state.js | 1 - src/core/endpoints/subscriptionUtils/handshake.js | 7 +++++++ src/core/endpoints/subscriptionUtils/receiveMessages.js | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/endpoints/presence/heartbeat.js b/src/core/endpoints/presence/heartbeat.js index 6ae910de9..293dea043 100644 --- a/src/core/endpoints/presence/heartbeat.js +++ b/src/core/endpoints/presence/heartbeat.js @@ -30,7 +30,7 @@ export function getRequestTimeout({ config }) { } export function prepareParams(modules, incomingParams) { - const { channelGroups = [], state = {} } = incomingParams; + const { channelGroups = [], state } = incomingParams; const { config } = modules; const params = {}; @@ -38,7 +38,9 @@ export function prepareParams(modules, incomingParams) { params['channel-group'] = channelGroups.join(','); } - params.state = JSON.stringify(state); + if (state) { + params.state = JSON.stringify(state); + } params.heartbeat = config.getPresenceTimeout(); return params; } diff --git a/src/core/endpoints/presence/set_state.js b/src/core/endpoints/presence/set_state.js index 05cd9e552..53f419a5d 100644 --- a/src/core/endpoints/presence/set_state.js +++ b/src/core/endpoints/presence/set_state.js @@ -42,7 +42,6 @@ export function prepareParams(modules, incomingParams) { if (channelGroups.length > 0) { params['channel-group'] = channelGroups.join(','); } - return params; } diff --git a/src/core/endpoints/subscriptionUtils/handshake.js b/src/core/endpoints/subscriptionUtils/handshake.js index 77e4e725f..84fd489fc 100644 --- a/src/core/endpoints/subscriptionUtils/handshake.js +++ b/src/core/endpoints/subscriptionUtils/handshake.js @@ -25,6 +25,13 @@ const endpoint = { outParams['channel-group'] = params.channelGroups.join(','); } outParams.tt = 0; + if (params.state) { + outParams.state = JSON.stringify(params.state); + } + if (params.filterExpression && params.filterExpression.length > 0) { + outParams['filter-expr'] = params.filterExpression; + } + outParams.ee = ''; return outParams; }, diff --git a/src/core/endpoints/subscriptionUtils/receiveMessages.js b/src/core/endpoints/subscriptionUtils/receiveMessages.js index 30c74e62b..5d259d868 100644 --- a/src/core/endpoints/subscriptionUtils/receiveMessages.js +++ b/src/core/endpoints/subscriptionUtils/receiveMessages.js @@ -32,8 +32,12 @@ const endpoint = { if (params.channelGroups && params.channelGroups.length > 0) { outParams['channel-group'] = params.channelGroups.join(','); } + if (params.filterExpression && params.filterExpression.length > 0) { + outParams['filter-expr'] = params.filterExpression; + } outParams.tt = params.timetoken; outParams.tr = params.region; + outParams.ee=''; return outParams; }, From c253e962cc46ac04ca8650d288919cfb6afb7dcb Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:28:43 +0530 Subject: [PATCH 26/63] updated PubNub with configurations --- src/core/components/config.js | 38 +++++++++++++++----------- src/core/constants/categories.js | 4 +++ src/core/pubnub-common.js | 46 +++++++++++++++++++++++++++----- 3 files changed, 66 insertions(+), 22 deletions(-) diff --git a/src/core/components/config.js b/src/core/components/config.js index b6a6bf3c3..87417c8ec 100644 --- a/src/core/components/config.js +++ b/src/core/components/config.js @@ -74,9 +74,8 @@ export default class { // when there changes in the networking autoNetworkDetection; - // to configure reconnection policy and maximumReconnectionRetry values - // default reconnection policy is PNReconnectionPolicy.NONE and maximumReconnectionRetry value is 0 - reconnectionConfiguration; + // configure retry policy configuration. + retryConfiguration; // alert when a heartbeat works out. announceSuccessfulHeartbeats; @@ -144,7 +143,8 @@ export default class { // How many times the publish-file should be retried before giving up fileUploadPublishRetryLimit; useRandomIVs; - enableSubscribeBeta; + enableEventEngine; + maintainPresenceState; constructor({ setup }) { this._PNSDKSuffix = {}; @@ -182,11 +182,8 @@ export default class { this.fileUploadPublishRetryLimit = setup.fileUploadPublishRetryLimit ?? 5; this.useRandomIVs = setup.useRandomIVs ?? true; - // flag for beta subscribe feature enablement - this.enableSubscribeBeta = setup.enableSubscribeBeta ?? false; - - // reconnection configuration settings to apply reconnection settings in subscription - this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; + this.enableEventEngine = setup.enableEventEngine ?? false; + this.maintainPresenceState = setup.maintainPresenceState ?? true; // if location config exist and we are in https, force secure to true. if (typeof location !== 'undefined' && location.protocol === 'https:') { @@ -204,6 +201,10 @@ export default class { this.requestMessageCountThreshold = setup.requestMessageCountThreshold; + if (setup.retryConfiguration) { + this.setRetryConfiguration(setup.retryConfiguration); + } + // set timeout to how long a transaction request will wait for the server (default 15 seconds) this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000); // set timeout to how long a subscribe event loop will run (default 310 seconds) @@ -349,12 +350,19 @@ export default class { return '7.2.3'; } - setReconnectionConfiguration(reconnectionPolicy, maximumReconnectionRetries) { - this.reconnectionConfiguration = { - ...config.reconnectionConfiguration, - reconnectionPolicy: reconnectionPolicy, - maximumReconnectionRetries: maximumReconnectionRetries, - }; + setRetryConfiguration(configuration) { + if (configuration.minimumdelay < 2) { + throw new Error('Minimum delay can not be set less than 2 seconds for retry'); + } + if (configuration.maximumDelay > 150) { + throw new Error('Maximum delay can not be set more than 150 seconds for retry'); + } + if (configuration.maximumDelay && maximumRetry > 6) { + throw new Error('Maximum retry for exponential retry policy can not be more than 6'); + } else if (configuration.maximumRetry > 10) { + throw new Error('Maximum retry for linear retry policy can not be more than 10'); + } + this.retryConfiguration = configuration; } _addPnsdkSuffix(name, suffix) { diff --git a/src/core/constants/categories.js b/src/core/constants/categories.js index 76809b824..bf48a79d1 100644 --- a/src/core/constants/categories.js +++ b/src/core/constants/categories.js @@ -29,4 +29,8 @@ export default { PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', PNDisconnectedCategory: 'PNDisconnectedCategory', + + PNConnectionErrorCategory: 'PNConnectionErrorCategory', + + PNDisconnectedUnexpectedlyCategory: 'PNDisconnectedUnexpectedlyCategory', }; diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 7e31f84dd..29349e596 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -90,7 +90,8 @@ import CATEGORIES from './constants/categories'; import uuidGenerator from './components/uuid'; import { EventEngine } from '../event-engine'; -import { ReconnectionDelay } from '../event-engine/core/reconnectionDelay'; +import { PresenceEventEngine } from '../event-engine/presence/presence'; +import { RetryPolicy } from '../event-engine/core/retryPolicy'; export default class { _config; @@ -320,15 +321,44 @@ export default class { this.handshake = endpointCreator.bind(this, modules, handshakeEndpointConfig); this.receiveMessages = endpointCreator.bind(this, modules, receiveMessagesConfig); - if (config.enableSubscribeBeta === true) { - let policy = modules.config.reconnectionConfiguration.reconnectionPolicy; - let maxRetries = modules.config.reconnectionConfiguration.maximumReconnectionRetries ?? 0; + if (config.enableEventEngine === true) { + if (config.maintainPresenceState) { + this.presenceState = {}; + this.setState = (args) => { + args.channels?.forEach((channel) => (this.presenceState[channel] = args.state)); + args.channelGroups?.forEach((group) => (this.presenceState[group] = args.state)); + return this.setPresenceState({ + channels: args.channels, + channelGroups: args.channelGroups, + state: this.presenceState, + }); + }; + } + + if (config.getHeartbeatInterval()) { + const presenceEventEngine = new PresenceEventEngine({ + heartbeat: this.iAmHere, + leave: this.iAmAway, + heartbeatDelay: () => + new Promise((resolve) => setTimeout(resolve, modules.config.getHeartbeatInterval() * 1000)), + retryDelay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), + config: modules.config, + presenceState: this.presenceState, + }); + this.presenceEventEngine = presenceEventEngine; + this.join = this.presenceEventEngine.join.bind(presenceEventEngine); + this.leave = this.presenceEventEngine.leave.bind(presenceEventEngine); + this.leaveAll = this.presenceEventEngine.leaveAll.bind(presenceEventEngine); + } const eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: (attempts) => ReconnectionDelay.getDelay(policy, attempts), delay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), - shouldRetry: (_, attempts) => maxRetries > attempts && policy && policy != 'None', + join: this.join, + leave: this.leave, + leaveAll: this.leaveAll, + presenceState: this.presenceState, + config: modules.config, emitEvents: (events) => { for (const event of events) { listenerManager.announceMessage(event); @@ -344,7 +374,6 @@ export default class { this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); this.reconnect = eventEngine.reconnect.bind(eventEngine); this.disconnect = eventEngine.disconnect.bind(eventEngine); - this.eventEngine = eventEngine; } else { const subscriptionManager = new SubscriptionManager({ @@ -737,4 +766,7 @@ export default class { static OPERATIONS = OPERATIONS; static CATEGORIES = CATEGORIES; + + static LinearRetryPolicy = RetryPolicy.LinearRetryPolicy; + static ExponentialRetryPolicy = RetryPolicy.ExponentialRetryPolicy; } From f7b92ad505bb11f64b5b6ede52e082448809aabc Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:29:56 +0530 Subject: [PATCH 27/63] lib and dist --- dist/web/pubnub.js | 748 +++++++++++++++--- dist/web/pubnub.min.js | 4 +- lib/core/components/config.js | 38 +- lib/core/constants/categories.js | 2 + lib/core/endpoints/presence/heartbeat.js | 6 +- .../endpoints/subscriptionUtils/handshake.js | 7 + .../subscriptionUtils/receiveMessages.js | 4 + lib/core/pubnub-common.js | 46 +- lib/event-engine/core/reconnectionDelay.js | 9 +- lib/event-engine/core/retryPolicy.js | 48 ++ lib/event-engine/dispatcher.js | 41 +- lib/event-engine/events.js | 10 +- lib/event-engine/index.js | 51 +- lib/event-engine/presence/dispatcher.js | 201 +++++ lib/event-engine/presence/effects.js | 14 + lib/event-engine/presence/events.js | 19 + lib/event-engine/presence/presence.js | 102 +++ .../presence/states/heartbeat_cooldown.js | 64 ++ .../presence/states/heartbeat_failed.js | 62 ++ .../presence/states/heartbeat_inactive.js | 14 + .../presence/states/heartbeat_reconnecting.js | 86 ++ .../presence/states/heartbeat_stopped.js | 61 ++ .../presence/states/heartbeating.js | 78 ++ lib/event-engine/states/handshake_failure.js | 6 - .../states/handshake_reconnecting.js | 20 +- lib/event-engine/states/handshake_stopped.js | 2 +- lib/event-engine/states/handshaking.js | 14 +- lib/event-engine/states/receive_failure.js | 37 +- .../states/receive_reconnecting.js | 24 +- lib/event-engine/states/receive_stopped.js | 28 +- lib/event-engine/states/receiving.js | 20 +- lib/event-engine/states/unsubscribed.js | 7 + 32 files changed, 1674 insertions(+), 199 deletions(-) create mode 100644 lib/event-engine/core/retryPolicy.js create mode 100644 lib/event-engine/presence/dispatcher.js create mode 100644 lib/event-engine/presence/effects.js create mode 100644 lib/event-engine/presence/events.js create mode 100644 lib/event-engine/presence/presence.js create mode 100644 lib/event-engine/presence/states/heartbeat_cooldown.js create mode 100644 lib/event-engine/presence/states/heartbeat_failed.js create mode 100644 lib/event-engine/presence/states/heartbeat_inactive.js create mode 100644 lib/event-engine/presence/states/heartbeat_reconnecting.js create mode 100644 lib/event-engine/presence/states/heartbeat_stopped.js create mode 100644 lib/event-engine/presence/states/heartbeating.js diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index 1a172524e..1e2ee66dc 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -611,7 +611,7 @@ var default_1$b = /** @class */ (function () { function default_1(_a) { var setup = _a.setup; - var _b, _c, _d; + var _b, _c, _d, _e; this._PNSDKSuffix = {}; this.instanceId = "pn-".concat(uuidGenerator.createUUID()); this.secretKey = setup.secretKey || setup.secret_key; @@ -639,10 +639,8 @@ this.customDecrypt = setup.customDecrypt; this.fileUploadPublishRetryLimit = (_b = setup.fileUploadPublishRetryLimit) !== null && _b !== void 0 ? _b : 5; this.useRandomIVs = (_c = setup.useRandomIVs) !== null && _c !== void 0 ? _c : true; - // flag for beta subscribe feature enablement - this.enableSubscribeBeta = (_d = setup.enableSubscribeBeta) !== null && _d !== void 0 ? _d : false; - // reconnection configuration settings to apply reconnection settings in subscription - this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; + this.enableEventEngine = (_d = setup.enableEventEngine) !== null && _d !== void 0 ? _d : false; + this.maintainPresenceState = (_e = setup.maintainPresenceState) !== null && _e !== void 0 ? _e : true; // if location config exist and we are in https, force secure to true. if (typeof location !== 'undefined' && location.protocol === 'https:') { this.secure = true; @@ -654,6 +652,9 @@ this.useInstanceId = setup.useInstanceId || false; this.useRequestId = setup.useRequestId || false; this.requestMessageCountThreshold = setup.requestMessageCountThreshold; + if (setup.retryConfiguration) { + this.setRetryConfiguration(setup.retryConfiguration); + } // set timeout to how long a transaction request will wait for the server (default 15 seconds) this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000); // set timeout to how long a subscribe event loop will run (default 310 seconds) @@ -772,8 +773,20 @@ default_1.prototype.getVersion = function () { return '7.2.3'; }; - default_1.prototype.setReconnectionConfiguration = function (reconnectionPolicy, maximumReconnectionRetries) { - this.reconnectionConfiguration = __assign(__assign({}, config.reconnectionConfiguration), { reconnectionPolicy: reconnectionPolicy, maximumReconnectionRetries: maximumReconnectionRetries }); + default_1.prototype.setRetryConfiguration = function (configuration) { + if (configuration.minimumdelay < 2) { + throw new Error('Minimum delay can not be set less than 2 seconds for retry'); + } + if (configuration.maximumDelay > 150) { + throw new Error('Maximum delay can not be set more than 150 seconds for retry'); + } + if (configuration.maximumDelay && maximumRetry > 6) { + throw new Error('Maximum retry for exponential retry policy can not be more than 6'); + } + else if (configuration.maximumRetry > 10) { + throw new Error('Maximum retry for linear retry policy can not be more than 10'); + } + this.retryConfiguration = configuration; }; default_1.prototype._addPnsdkSuffix = function (name, suffix) { this._PNSDKSuffix[name] = suffix; @@ -1782,6 +1795,8 @@ PNConnectedCategory: 'PNConnectedCategory', PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', PNDisconnectedCategory: 'PNDisconnectedCategory', + PNConnectionErrorCategory: 'PNConnectionErrorCategory', + PNDisconnectedUnexpectedlyCategory: 'PNDisconnectedUnexpectedlyCategory', }; var default_1$7 = /** @class */ (function () { @@ -4120,13 +4135,15 @@ return config.getTransactionTimeout(); } function prepareParams$h(modules, incomingParams) { - var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, _b = incomingParams.state, state = _b === void 0 ? {} : _b; + var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, state = incomingParams.state; var config = modules.config; var params = {}; if (channelGroups.length > 0) { params['channel-group'] = channelGroups.join(','); } - params.state = JSON.stringify(state); + if (state) { + params.state = JSON.stringify(state); + } params.heartbeat = config.getPresenceTimeout(); return params; } @@ -6582,6 +6599,13 @@ outParams['channel-group'] = params.channelGroups.join(','); } outParams.tt = 0; + if (params.state) { + outParams.state = JSON.stringify(params.state); + } + if (params.filterExpression && params.filterExpression.length > 0) { + outParams['filter-expr'] = params.filterExpression; + } + outParams.ee = ''; return outParams; }, handleResponse: function (_, response) { return ({ @@ -6619,8 +6643,12 @@ if (params.channelGroups && params.channelGroups.length > 0) { outParams['channel-group'] = params.channelGroups.join(','); } + if (params.filterExpression && params.filterExpression.length > 0) { + outParams['filter-expr'] = params.filterExpression; + } outParams.tt = params.timetoken; outParams.tr = params.region; + outParams.ee = ''; return outParams; }, handleResponse: function (_, response) { @@ -6976,7 +7004,7 @@ var receiveEvents = createManagedEffect('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); var emitEvents = createEffect('EMIT_MESSAGES', function (events) { return events; }); var emitStatus = createEffect('EMIT_STATUS', function (status) { return status; }); - var reconnect$1 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); + var reconnect$2 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ @@ -6984,9 +7012,9 @@ groups: groups, timetoken: timetoken, }); }); - var disconnect = createEvent('DISCONNECT', function () { return ({}); }); - var reconnect = createEvent('RECONNECT', function () { return ({}); }); - var restore = createEvent('RESTORE', function (channels, groups, timetoken, region) { return ({ + var disconnect$1 = createEvent('DISCONNECT', function () { return ({}); }); + var reconnect$1 = createEvent('RECONNECT', function () { return ({}); }); + var restore = createEvent('SUBSCRIPTION_RESTORED', function (channels, groups, timetoken, region) { return ({ channels: channels, groups: groups, timetoken: timetoken, @@ -6999,7 +7027,6 @@ }); }); var handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); var handshakingReconnectingGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', function () { return ({}); }); - var handshakingReconnectingRetry = createEvent('HANDSHAKING_RECONNECTING_RETRY', function () { return ({}); }); var receivingSuccess = createEvent('RECEIVE_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, @@ -7009,16 +7036,17 @@ cursor: cursor, events: events, }); }); - var reconnectingFailure = createEvent('RECEIVING_RECONNECTING_FAILURE', function (error) { return error; }); + var reconnectingFailure = createEvent('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); var reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); - var reconnectingRetry = createEvent('RECEIVING_RECONNECTING_RETRY', function () { return ({}); }); + var reconnectingRetry = createEvent('RECONNECT', function () { return ({}); }); + var unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', function () { }); var EventEngineDispatcher = /** @class */ (function (_super) { __extends(EventEngineDispatcher, _super); function EventEngineDispatcher(engine, dependencies) { var _this = _super.call(this, dependencies) || this; _this.on(handshake.type, asyncHandler(function (payload, abortSignal, _a) { - var handshake = _a.handshake; + var handshake = _a.handshake, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, e_1; return __generator(this, function (_b) { @@ -7032,11 +7060,12 @@ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, + filterExpression: config.filterExpression, + state: presenceState, })]; case 2: result = _b.sent(); - engine.transition(handshakingSuccess(result)); - return [3 /*break*/, 4]; + return [2 /*return*/, engine.transition(handshakingSuccess(result))]; case 3: e_1 = _b.sent(); if (e_1 instanceof Error && e_1.message === 'Aborted') { @@ -7052,7 +7081,7 @@ }); })); _this.on(receiveEvents.type, asyncHandler(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents; + var receiveEvents = _a.receiveEvents, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_1; return __generator(this, function (_b) { @@ -7068,6 +7097,7 @@ channelGroups: payload.groups, timetoken: payload.cursor.timetoken, region: payload.cursor.region, + filterExpression: config.filterExpression, })]; case 2: result = _b.sent(); @@ -7087,7 +7117,7 @@ }); }); })); - _this.on(emitEvents.type, asyncHandler(function (payload, abortSignal, _a) { + _this.on(emitEvents.type, asyncHandler(function (payload, _, _a) { var emitEvents = _a.emitEvents; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { @@ -7098,7 +7128,7 @@ }); }); })); - _this.on(emitStatus.type, asyncHandler(function (payload, abortSignal, _a) { + _this.on(emitStatus.type, asyncHandler(function (payload, _, _a) { var emitStatus = _a.emitStatus; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { @@ -7107,18 +7137,16 @@ }); }); })); - _this.on(reconnect$1.type, asyncHandler(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; + _this.on(reconnect$2.type, asyncHandler(function (payload, abortSignal, _a) { + var receiveEvents = _a.receiveEvents, delay = _a.delay, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_2; return __generator(this, function (_b) { switch (_b.label) { case 0: - if (!shouldRetry(payload.reason, payload.attempts)) { - return [2 /*return*/, engine.transition(reconnectingGiveup())]; - } + if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; case 1: _b.sent(); abortSignal.throwIfAborted(); @@ -7131,6 +7159,7 @@ channelGroups: payload.groups, timetoken: payload.cursor.timetoken, region: payload.cursor.region, + filterExpression: config.filterExpression, })]; case 3: result = _b.sent(); @@ -7144,23 +7173,23 @@ return [2 /*return*/, engine.transition(reconnectingFailure(error_2))]; } return [3 /*break*/, 5]; - case 5: return [2 /*return*/]; + case 5: return [3 /*break*/, 7]; + case 6: return [2 /*return*/, engine.transition(reconnectingGiveup())]; + case 7: return [2 /*return*/]; } }); }); })); _this.on(handshakeReconnect.type, asyncHandler(function (payload, abortSignal, _a) { - var handshake = _a.handshake, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; + var handshake = _a.handshake, delay = _a.delay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_3; return __generator(this, function (_b) { switch (_b.label) { case 0: - if (!shouldRetry(payload.reason, payload.attempts)) { - return [2 /*return*/, engine.transition(handshakingReconnectingGiveup())]; - } + if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; case 1: _b.sent(); abortSignal.throwIfAborted(); @@ -7171,6 +7200,8 @@ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, + filterExpression: config.filterExpression, + state: presenceState, })]; case 3: result = _b.sent(); @@ -7184,7 +7215,9 @@ return [2 /*return*/, engine.transition(handshakingReconnectingFailure(error_3))]; } return [3 /*break*/, 5]; - case 5: return [2 /*return*/]; + case 5: return [3 /*break*/, 7]; + case 6: return [2 /*return*/, engine.transition(handshakingReconnectingGiveup())]; + case 7: return [2 /*return*/]; } }); }); @@ -7194,27 +7227,23 @@ return EventEngineDispatcher; }(Dispatcher)); - var HandshakeStoppedState = new State('STOPPED'); + var HandshakeStoppedState = new State('HANDSHAKE_STOPPED'); HandshakeStoppedState.on(subscriptionChange.type, function (_, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, }); }); - HandshakeStoppedState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); + HandshakeStoppedState.on(reconnect$1.type, function (context) { return HandshakingState.with(__assign({}, context)); }); var HandshakeFailureState = new State('HANDSHAKE_FAILURE'); - HandshakeFailureState.onEnter(function (context) { return emitStatus({ category: 'PNNetworkIssuesCategory' }); }); - HandshakeFailureState.on(handshakingReconnectingRetry.type, function (context) { - return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); - }); - HandshakeFailureState.on(disconnect.type, function (context) { + HandshakeFailureState.on(disconnect$1.type, function (context) { return HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, }); }); - HandshakeFailureState.on(reconnect.type, function (context) { return HandshakingState.with(__assign({}, context)); }); + HandshakeFailureState.on(reconnect$1.type, function (context) { return HandshakingState.with(__assign({}, context)); }); var ReceiveStoppedState = new State('STOPPED'); ReceiveStoppedState.on(subscriptionChange.type, function (context, event) { @@ -7224,23 +7253,55 @@ cursor: context.cursor, }); }); - ReceiveStoppedState.on(reconnect.type, function (context) { return ReceivingState.with(__assign({}, context)); }); + ReceiveStoppedState.on(restore.type, function (context, event) { + return ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); + }); + ReceiveStoppedState.on(reconnect$1.type, function (context) { + return HandshakingState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + ReceiveStoppedState.on(unsubscribeAll.type, function () { return UnsubscribedState.with(undefined); }); - var ReceiveFailureState = new State('RECEIVE_FAILURE'); + var ReceiveFailureState = new State('RECEIVE_FAILED'); ReceiveFailureState.on(reconnectingRetry.type, function (context) { - return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); + return HandshakingState.with({ + channels: context.channels, + groups: context.groups, + timetoken: context.cursor.timetoken, + }); }); - ReceiveFailureState.on(disconnect.type, function (context) { + ReceiveFailureState.on(disconnect$1.type, function (context) { return ReceiveStoppedState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, }); }); + ReceiveFailureState.on(subscriptionChange.type, function (_, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); + }); + ReceiveFailureState.on(restore.type, function (_, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); + }); + ReceiveFailureState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(undefined); }); var ReceiveReconnectingState = new State('RECEIVE_RECONNECTING'); - ReceiveReconnectingState.onEnter(function (context) { return reconnect$1(context); }); - ReceiveReconnectingState.onExit(function () { return reconnect$1.cancel; }); + ReceiveReconnectingState.onEnter(function (context) { return reconnect$2(context); }); + ReceiveReconnectingState.onExit(function () { return reconnect$2.cancel; }); ReceiveReconnectingState.on(reconnectingSuccess.type, function (context, event) { return ReceivingState.with({ channels: context.channels, @@ -7257,20 +7318,24 @@ channels: context.channels, cursor: context.cursor, reason: context.reason, - }, [emitStatus({ category: 'PNDisconnectedCategory' })]); + }, [emitStatus({ category: categories.PNDisconnectedUnexpectedlyCategory })]); }); - ReceiveReconnectingState.on(disconnect.type, function (context) { + ReceiveReconnectingState.on(disconnect$1.type, function (context) { return ReceiveStoppedState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, - }, [emitStatus({ category: 'PNDisconnectedCategory' })]); + }, [emitStatus({ category: categories.PNDisconnectedCategory })]); }); - ReceiveReconnectingState.on(restore.type, function (context) { + ReceiveReconnectingState.on(restore.type, function (context, event) { + var _a, _b; return ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: (_a = event.payload.timetoken) !== null && _a !== void 0 ? _a : context.cursor.timetoken, + region: (_b = event.payload.region) !== null && _b !== void 0 ? _b : context.cursor.region, + }, }); }); ReceiveReconnectingState.on(subscriptionChange.type, function (context, event) { @@ -7280,40 +7345,52 @@ cursor: context.cursor, }); }); + ReceiveReconnectingState.on(unsubscribeAll.type, function (_) { + return UnsubscribedState.with(undefined, [emitStatus({ category: categories.PNDisconnectedCategory })]); + }); var ReceivingState = new State('RECEIVING'); - ReceivingState.onEnter(function (_) { return emitStatus({ category: 'PNConnectedCategory' }); }); ReceivingState.onEnter(function (context) { return receiveEvents(context.channels, context.groups, context.cursor); }); ReceivingState.onExit(function () { return receiveEvents.cancel; }); ReceivingState.on(receivingSuccess.type, function (context, event) { - return ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [emitEvents(event.payload.events)]); + return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor }, [ + emitEvents(event.payload.events), + ]); }); ReceivingState.on(subscriptionChange.type, function (context, event) { if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { return UnsubscribedState.with(undefined); } - return ReceivingState.with(__assign(__assign({}, context), { channels: event.payload.channels, groups: event.payload.groups })); + return ReceivingState.with({ + cursor: context.cursor, + channels: event.payload.channels, + groups: event.payload.groups, + }); }); ReceivingState.on(receivingFailure.type, function (context, event) { return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); }); - ReceivingState.on(disconnect.type, function (context) { + ReceivingState.on(disconnect$1.type, function (context) { return ReceiveStoppedState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, - }, [emitStatus({ category: 'PNDisconnectedCategory' })]); + }, [emitStatus({ category: categories.PNDisconnectedCategory })]); + }); + ReceivingState.on(unsubscribeAll.type, function (_) { + return UnsubscribedState.with(undefined, [emitStatus({ category: categories.PNDisconnectedCategory })]); }); var HandshakeReconnectingState = new State('HANDSHAKE_RECONNECTING'); HandshakeReconnectingState.onEnter(function (context) { return handshakeReconnect(context); }); HandshakeReconnectingState.onExit(function () { return handshakeReconnect.cancel; }); HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, function (context, event) { + var cursor = context.timetoken ? { timetoken: context.timetoken, region: 1 } : event.payload.cursor; return ReceivingState.with({ channels: context.channels, groups: context.groups, - cursor: event.payload.cursor, - }); + cursor: cursor, + }, [emitStatus({ category: categories.PNConnectedCategory })]); }); HandshakeReconnectingState.on(handshakingReconnectingFailure.type, function (context, event) { return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); @@ -7323,17 +7400,23 @@ groups: context.groups, channels: context.channels, reason: context.reason, - }); + }, [emitStatus({ category: categories.PNConnectionErrorCategory })]); }); - HandshakeReconnectingState.on(disconnect.type, function (context) { + HandshakeReconnectingState.on(disconnect$1.type, function (context) { return HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - }); + }, [emitStatus({ category: categories.PNDisconnectedCategory })]); }); HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); + HandshakeReconnectingState.on(restore.type, function (_, event) { + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + }); + HandshakeReconnectingState.on(unsubscribeAll.type, function (_) { + return UnsubscribedState.with(undefined, [emitStatus({ category: categories.PNDisconnectedCategory })]); + }); var HandshakingState = new State('HANDSHAKING'); HandshakingState.onEnter(function (context) { return handshake(context.channels, context.groups); }); @@ -7352,17 +7435,25 @@ timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, region: event.payload.region, }, - }); + }, [emitStatus({ category: categories.PNConnectedCategory })]); }); HandshakingState.on(handshakingFailure.type, function (context, event) { return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); }); - HandshakingState.on(disconnect.type, function (context) { + HandshakingState.on(disconnect$1.type, function (context) { return HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, }); }); + HandshakingState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(); }); + HandshakingState.on(restore.type, function (_, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); + }); var UnsubscribedState = new State('UNSUBSCRIBED'); UnsubscribedState.on(subscriptionChange.type, function (_, event) { @@ -7372,6 +7463,13 @@ timetoken: event.payload.timetoken, }); }); + UnsubscribedState.on(restore.type, function (_, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); + }); var EventEngine = /** @class */ (function () { function EventEngine(dependencies) { @@ -7379,6 +7477,7 @@ this.engine = new Engine(); this.channels = []; this.groups = []; + this.dependencies = dependencies; this.dispatcher = new EventEngineDispatcher(this.engine, dependencies); this._unsubscribeEngine = this.engine.subscribe(function (change) { if (change.type === 'invocationDispatched') { @@ -7395,27 +7494,67 @@ configurable: true }); EventEngine.prototype.subscribe = function (_a) { - var channels = _a.channels, groups = _a.groups, timetoken = _a.timetoken; + var _this = this; + var channels = _a.channels, channelGroups = _a.channelGroups, timetoken = _a.timetoken, withPresence = _a.withPresence; this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); - this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); - this.engine.transition(subscriptionChange(this.channels, this.groups, timetoken !== null && timetoken !== void 0 ? timetoken : '0')); + this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])), false); + if (withPresence) { + this.channels.map(function (c) { return _this.channels.push("".concat(c, "-pnpres")); }); + this.groups.map(function (g) { return _this.groups.push("".concat(g, "-pnpres")); }); + } + if (timetoken) { + this.engine.transition(restore(this.channels, this.groups, timetoken)); + } + else { + this.engine.transition(subscriptionChange(this.channels, this.groups)); + } + if (this.dependencies.join) { + this.dependencies.join({ + channels: this.channels.filter(function (c) { return !c.endsWith('-pnpres'); }), + groups: this.groups.filter(function (g) { return !g.endsWith('-pnpres'); }), + }); + } }; EventEngine.prototype.unsubscribe = function (_a) { + var _this = this; var channels = _a.channels, groups = _a.groups; - this.channels = this.channels.filter(function (channel) { var _a; return (_a = !(channels === null || channels === void 0 ? void 0 : channels.includes(channel))) !== null && _a !== void 0 ? _a : true; }); - this.groups = this.groups.filter(function (group) { var _a; return (_a = !(groups === null || groups === void 0 ? void 0 : groups.includes(group))) !== null && _a !== void 0 ? _a : true; }); + var channlesWithPres = channels === null || channels === void 0 ? void 0 : channels.slice(0); + channels === null || channels === void 0 ? void 0 : channels.map(function (c) { return channlesWithPres.push("".concat(c, "-pnpres")); }); + this.channels = this.channels.filter(function (channel) { return !(channlesWithPres === null || channlesWithPres === void 0 ? void 0 : channlesWithPres.includes(channel)); }); + var groupsWithPres = groups === null || groups === void 0 ? void 0 : groups.slice(0); + groups === null || groups === void 0 ? void 0 : groups.map(function (g) { return groupsWithPres.push("".concat(g, "-pnpres")); }); + this.groups = this.groups.filter(function (group) { return !(groupsWithPres === null || groupsWithPres === void 0 ? void 0 : groupsWithPres.includes(group)); }); + if (this.dependencies.presenceState) { + channels === null || channels === void 0 ? void 0 : channels.forEach(function (c) { return delete _this.dependencies.presenceState[c]; }); + groups === null || groups === void 0 ? void 0 : groups.forEach(function (g) { return delete _this.dependencies.presenceState[g]; }); + } this.engine.transition(subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + if (this.dependencies.leave) { + this.dependencies.leave({ + channels: channels, + groups: groups, + }); + } }; EventEngine.prototype.unsubscribeAll = function () { this.channels = []; this.groups = []; + if (this.dependencies.presenceState) { + this.dependencies.presenceState = {}; + } this.engine.transition(subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + if (this.dependencies.leaveAll) { + this.dependencies.leaveAll(); + } }; EventEngine.prototype.reconnect = function () { - this.engine.transition(reconnect()); + this.engine.transition(reconnect$1()); }; EventEngine.prototype.disconnect = function () { - this.engine.transition(disconnect()); + this.engine.transition(disconnect$1()); + if (this.dependencies.leaveAll) { + this.dependencies.leaveAll(); + } }; EventEngine.prototype.dispose = function () { this.disconnect(); @@ -7425,28 +7564,419 @@ return EventEngine; }()); - var ReconnectionDelay = /** @class */ (function () { - function ReconnectionDelay() { + var reconnect = createEvent('RECONNECT', function () { return ({}); }); + var disconnect = createEvent('DISCONNECT', function () { return ({}); }); + var joined = createEvent('JOINED', function (channels, groups) { return ({ + channels: channels, + groups: groups, + }); }); + var left = createEvent('LEFT', function (channels, groups) { return ({ + channels: channels, + groups: groups, + }); }); + var leftAll = createEvent('LEFT_ALL', function () { return ({}); }); + var heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', function () { return ({}); }); + var heartbeatFailure = createEvent('HEARTBEAT_FAILURE', function (error) { return error; }); + var heartbeatGiveup = createEvent('HEARTBEAT_GIVEUP', function () { return ({}); }); + var timesUp = createEvent('TIMES_UP', function () { return ({}); }); + + var heartbeat = createEffect('HEARTBEAT', function (channels, groups) { return ({ + channels: channels, + groups: groups, + }); }); + var leave = createEffect('LEAVE', function (channels, groups) { return ({ + channels: channels, + groups: groups, + }); }); + var wait = createManagedEffect('WAIT', function () { return ({}); }); + var delayedHeartbeat = createManagedEffect('DELAYED_HEARTBEAT', function (context) { return context; }); + + var PresenceEventEngineDispatcher = /** @class */ (function (_super) { + __extends(PresenceEventEngineDispatcher, _super); + function PresenceEventEngineDispatcher(engine, dependencies) { + var _this = _super.call(this, dependencies) || this; + _this.on(heartbeat.type, asyncHandler(function (payload, _, _a) { + var heartbeat = _a.heartbeat, presenceState = _a.presenceState; + return __awaiter(_this, void 0, void 0, function () { + var e_1; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 2, , 3]); + return [4 /*yield*/, heartbeat({ + channels: payload.channels, + channelGroups: payload.groups, + state: presenceState, + })]; + case 1: + _b.sent(); + engine.transition(heartbeatSuccess()); + return [3 /*break*/, 3]; + case 2: + e_1 = _b.sent(); + if (e_1 instanceof PubNubError) { + return [2 /*return*/, engine.transition(heartbeatFailure(e_1))]; + } + return [3 /*break*/, 3]; + case 3: return [2 /*return*/]; + } + }); + }); + })); + _this.on(leave.type, asyncHandler(function (payload, _, _a) { + var leave = _a.leave, config = _a.config; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!!config.suppressLeaveEvents) return [3 /*break*/, 4]; + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + return [4 /*yield*/, leave({ + channels: payload.channels, + channelGroups: payload.groups, + })]; + case 2: + _b.sent(); + return [3 /*break*/, 4]; + case 3: + _b.sent(); + return [3 /*break*/, 4]; + case 4: return [2 /*return*/]; + } + }); + }); + })); + _this.on(wait.type, asyncHandler(function (_, abortSignal, _a) { + var heartbeatDelay = _a.heartbeatDelay; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + abortSignal.throwIfAborted(); + return [4 /*yield*/, heartbeatDelay()]; + case 1: + _b.sent(); + abortSignal.throwIfAborted(); + return [2 /*return*/, engine.transition(timesUp())]; + } + }); + }); + })); + _this.on(delayedHeartbeat.type, asyncHandler(function (payload, abortSignal, _a) { + var heartbeat = _a.heartbeat, retryDelay = _a.retryDelay, presenceState = _a.presenceState, config = _a.config; + return __awaiter(_this, void 0, void 0, function () { + var e_3; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; + abortSignal.throwIfAborted(); + return [4 /*yield*/, retryDelay(config.retryConfiguration.getDelay(payload.attempts))]; + case 1: + _b.sent(); + abortSignal.throwIfAborted(); + _b.label = 2; + case 2: + _b.trys.push([2, 4, , 5]); + return [4 /*yield*/, heartbeat({ + channels: payload.channels, + channelGroups: payload.groups, + state: presenceState, + })]; + case 3: + _b.sent(); + console.log("after hb call"); + return [2 /*return*/, engine.transition(heartbeatSuccess())]; + case 4: + e_3 = _b.sent(); + if (e_3 instanceof Error && e_3.message === 'Aborted') { + return [2 /*return*/]; + } + if (e_3 instanceof PubNubError) { + return [2 /*return*/, engine.transition(heartbeatFailure(e_3))]; + } + return [3 /*break*/, 5]; + case 5: return [3 /*break*/, 7]; + case 6: return [2 /*return*/, engine.transition(heartbeatGiveup())]; + case 7: return [2 /*return*/]; + } + }); + }); + })); + return _this; } - ReconnectionDelay.getDelay = function (policy, attempts, backoff) { - var backoffValue = backoff !== null && backoff !== void 0 ? backoff : 5; - switch (policy.toUpperCase()) { - case 'LINEAR': - return attempts * backoffValue + Math.random() * 1000; - case 'EXPONENTIAL': - return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; - default: - throw new Error('invalid policy'); + return PresenceEventEngineDispatcher; + }(Dispatcher)); + + var HeartbeatStoppedState = new State('HEARTBEAT_STOPPED'); + HeartbeatStoppedState.on(joined.type, function (context, event) { + return HeartbeatStoppedState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); + }); + HeartbeatStoppedState.on(left.type, function (context, event) { + return HeartbeatStoppedState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [leave(event.payload.channels, event.payload.groups)]); + }); + HeartbeatStoppedState.on(reconnect.type, function (context, _) { + return HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HeartbeatStoppedState.on(disconnect.type, function (context, _) { + return HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [leave(context.channels, context.groups)]); + }); + HeartbeatStoppedState.on(leftAll.type, function (context, _) { + return HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]); + }); + + var HeartbeatCooldownState = new State('HEARTBEATCOOLDOWN'); + HeartbeatCooldownState.onEnter(function () { return wait(); }); + HeartbeatCooldownState.onExit(function () { return wait.cancel; }); + HeartbeatCooldownState.on(timesUp.type, function (context, _) { + return HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HeartbeatCooldownState.on(joined.type, function (context, event) { + return HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); + }); + HeartbeatCooldownState.on(left.type, function (context, event) { + return HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [leave(event.payload.channels, event.payload.groups)]); + }); + HeartbeatCooldownState.on(disconnect.type, function (context) { + return HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [leave(context.channels, context.groups)]); + }); + HeartbeatCooldownState.on(leftAll.type, function (context, _) { + return HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]); + }); + + var HeartbeatFailedState = new State('HEARTBEAT_FAILED'); + HeartbeatFailedState.on(joined.type, function (context, event) { + return HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); + }); + HeartbeatFailedState.on(left.type, function (context, event) { + return HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [leave(event.payload.channels, event.payload.groups)]); + }); + HeartbeatFailedState.on(reconnect.type, function (context, _) { + return HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HeartbeatFailedState.on(disconnect.type, function (context, _) { + return HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [leave(context.channels, context.groups)]); + }); + HeartbeatFailedState.on(leftAll.type, function (context, _) { + return HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]); + }); + + var HearbeatReconnectingState = new State('HEARBEAT_RECONNECTING'); + HearbeatReconnectingState.onEnter(function (context) { return delayedHeartbeat(context); }); + HearbeatReconnectingState.onExit(function () { return delayedHeartbeat.cancel; }); + HearbeatReconnectingState.on(joined.type, function (context, event) { + return HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); + }); + HearbeatReconnectingState.on(left.type, function (context, event) { + return HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [leave(event.payload.channels, event.payload.groups)]); + }); + HearbeatReconnectingState.on(disconnect.type, function (context, _) { + HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [leave(context.channels, context.groups)]); + }); + HearbeatReconnectingState.on(heartbeatSuccess.type, function (context, _) { + return HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HearbeatReconnectingState.on(heartbeatFailure.type, function (context, event) { + return HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); + }); + HearbeatReconnectingState.on(heartbeatGiveup.type, function (context, event) { + return HeartbeatFailedState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HearbeatReconnectingState.on(leftAll.type, function (context, _) { + return HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]); + }); + + var HeartbeatingState = new State('HEARTBEATING'); + HeartbeatingState.onEnter(function (context) { return heartbeat(context.channels, context.groups); }); + HeartbeatingState.on(heartbeatSuccess.type, function (context, _) { + return HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups, + }); + }); + HeartbeatingState.on(joined.type, function (context, event) { + return HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); + }); + HeartbeatingState.on(left.type, function (context, event) { + return HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [leave(event.payload.channels, event.payload.groups)]); + }); + HeartbeatingState.on(heartbeatFailure.type, function (context, event) { + return HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); + }); + HeartbeatingState.on(disconnect.type, function (context) { + return HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [leave(context.channels, context.groups)]); + }); + HeartbeatingState.on(leftAll.type, function (context, _) { + return HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]); + }); + + var HeartbeatInactiveState = new State('HEARTBEAT_INACTIVE'); + HeartbeatInactiveState.on(joined.type, function (_, event) { + return HeartbeatingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + }); + }); + HeartbeatInactiveState.on(left.type, function (_, event) { return HeartbeatInactiveState.with(); }); + + var PresenceEventEngine = /** @class */ (function () { + function PresenceEventEngine(dependencies) { + var _this = this; + this.engine = new Engine(); + this.channels = []; + this.groups = []; + this.dispatcher = new PresenceEventEngineDispatcher(this.engine, dependencies); + this.dependencies = dependencies; + this._unsubscribeEngine = this.engine.subscribe(function (change) { + if (change.type === 'invocationDispatched') { + _this.dispatcher.dispatch(change.invocation); + } + }); + this.engine.start(HeartbeatInactiveState, undefined); + } + Object.defineProperty(PresenceEventEngine.prototype, "_engine", { + get: function () { + return this.engine; + }, + enumerable: false, + configurable: true + }); + PresenceEventEngine.prototype.join = function (_a) { + var channels = _a.channels, groups = _a.groups; + this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); + this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); + this.engine.transition(joined(this.channels.slice(0), this.groups.slice(0))); + }; + PresenceEventEngine.prototype.leave = function (_a) { + var _this = this; + var channels = _a.channels, groups = _a.groups; + if (this.dependencies.presenceState) { + channels === null || channels === void 0 ? void 0 : channels.forEach(function (c) { return delete _this.dependencies.presenceState[c]; }); + groups === null || groups === void 0 ? void 0 : groups.forEach(function (g) { return delete _this.dependencies.presenceState[g]; }); } + this.engine.transition(left(channels !== null && channels !== void 0 ? channels : [], groups !== null && groups !== void 0 ? groups : [])); + }; + PresenceEventEngine.prototype.leaveAll = function () { + this.engine.transition(leftAll()); }; - return ReconnectionDelay; + PresenceEventEngine.prototype.dispose = function () { + this._unsubscribeEngine(); + this.dispatcher.dispose(); + }; + return PresenceEventEngine; + }()); + + var RetryPolicy = /** @class */ (function () { + function RetryPolicy() { + } + RetryPolicy.LinearRetryPolicy = function (configuration) { + return { + delay: configuration.delay, + maximumRetry: configuration.maximumRetry, + shouldRetry: function (error, attempt) { + var _a; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return false; + } + return this.maximumRetry > attempt; + }, + getDelay: function (_) { + return this.delay * 1000; + }, + }; + }; + RetryPolicy.ExponentialRetryPolicy = function (configuration) { + return { + minimumDelay: configuration.minimumDelay, + maximumDelay: configuration.maximumDelay, + maximumRetry: configuration.maximumRetry, + shouldRetry: function (error, attempt) { + var _a; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return false; + } + return this.maximumRetry > attempt; + }, + getDelay: function (attempt) { + var calculatedDelay = Math.trunc(Math.pow(2, attempt)) * 1000 + Math.random() * 1000; + if (calculatedDelay > 150000) { + return 150000; + } + else { + return calculatedDelay; + } + }, + }; + }; + return RetryPolicy; }()); var default_1$3 = /** @class */ (function () { // function default_1(setup) { var _this = this; - var _a; var networking = setup.networking, cbor = setup.cbor; var config = new default_1$b({ setup: setup }); this._config = config; @@ -7484,15 +8014,45 @@ this.setPresenceState = endpointCreator.bind(this, modules, presenceSetStateConfig); this.handshake = endpointCreator.bind(this, modules, endpoint$1); this.receiveMessages = endpointCreator.bind(this, modules, endpoint); - if (config.enableSubscribeBeta === true) { - var policy_1 = modules.config.reconnectionConfiguration.reconnectionPolicy; - var maxRetries_1 = (_a = modules.config.reconnectionConfiguration.maximumReconnectionRetries) !== null && _a !== void 0 ? _a : 0; + if (config.enableEventEngine === true) { + if (config.maintainPresenceState) { + this.presenceState = {}; + this.setState = function (args) { + var _a, _b; + (_a = args.channels) === null || _a === void 0 ? void 0 : _a.forEach(function (channel) { return (_this.presenceState[channel] = args.state); }); + (_b = args.channelGroups) === null || _b === void 0 ? void 0 : _b.forEach(function (group) { return (_this.presenceState[group] = args.state); }); + return _this.setPresenceState({ + channels: args.channels, + channelGroups: args.channelGroups, + state: _this.presenceState, + }); + }; + } + if (config.getHeartbeatInterval()) { + var presenceEventEngine = new PresenceEventEngine({ + heartbeat: this.iAmHere, + leave: this.iAmAway, + heartbeatDelay: function () { + return new Promise(function (resolve) { return setTimeout(resolve, modules.config.getHeartbeatInterval() * 1000); }); + }, + retryDelay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, + config: modules.config, + presenceState: this.presenceState, + }); + this.presenceEventEngine = presenceEventEngine; + this.join = this.presenceEventEngine.join.bind(presenceEventEngine); + this.leave = this.presenceEventEngine.leave.bind(presenceEventEngine); + this.leaveAll = this.presenceEventEngine.leaveAll.bind(presenceEventEngine); + } var eventEngine = new EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return ReconnectionDelay.getDelay(policy_1, attempts); }, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (_, attempts) { return maxRetries_1 > attempts && policy_1 && policy_1 != 'None'; }, + join: this.join, + leave: this.leave, + leaveAll: this.leaveAll, + presenceState: this.presenceState, + config: modules.config, emitEvents: function (events) { var e_1, _a; try { @@ -7866,6 +8426,8 @@ }; default_1.OPERATIONS = OPERATIONS; default_1.CATEGORIES = categories; + default_1.LinearRetryPolicy = RetryPolicy.LinearRetryPolicy; + default_1.ExponentialRetryPolicy = RetryPolicy.ExponentialRetryPolicy; return default_1; }()); diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 9a82e99f9..7290bf6e9 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function y(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var v=function e(){var i,h,v=l(),b=v>>5,m=31&v;if(7===b)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(m))<0&&(b<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=g(b))>=0;)y(w,h);else y(w,h);return String.fromCharCode.apply(null,w);case 4:var T;if(h<0)for(T=[];!f();)T.push(e());else for(T=new Array(h),i=0;i0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i>2,c=0;c>6),i.push(128|63&s)):s<55296?(i.push(224|s>>12),i.push(128|s>>6&63),i.push(128|63&s)):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++r),s+=65536,i.push(240|s>>18),i.push(128|s>>12&63),i.push(128|s>>6&63),i.push(128|63&s))}return h(3,i.length),p(i);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof o&&(o=function(){return n});var v=function e(){var i,h,v=l(),m=v>>5,b=31&v;if(7===m)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),i=32768&n,o=31744&n,s=1023&n;if(31744===o)o=261120;else if(0!==o)o+=114688;else if(0!==s)return s*r;return t.setUint32(0,i<<16|o<<13|s<<13),t.getFloat32(0)}();case 26:return u(s.getFloat32(a),4);case 27:return u(s.getFloat64(a),8)}if((h=d(b))<0&&(m<2||6=0;)O+=h,_.push(c(h));var P=new Uint8Array(O),S=0;for(i=0;i<_.length;++i)P.set(_[i],S),S+=_[i].length;return P}return c(h);case 3:var w=[];if(h<0)for(;(h=y(m))>=0;)g(w,h);else g(w,h);return String.fromCharCode.apply(null,w);case 4:var E;if(h<0)for(E=[];!f();)E.push(e());else for(E=new Array(h),i=0;i=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.3"},e.prototype.setReconnectionConfiguration=function(e,t){this.reconnectionConfiguration=n(n({},config.reconnectionConfiguration),{reconnectionPolicy:e,maximumReconnectionRetries:t})},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function y(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,b,m,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],g=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],g=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+g|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),b=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=b.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],g=e[o+7],y=e[o+8],v=e[o+9],b=e[o+10],m=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],E=s[1],k=s[2],T=s[3],u,7,c[0]),T=t(T,w,E,k,a,12,c[1]),k=t(k,T,w,E,l,17,c[2]),E=t(E,k,T,w,p,22,c[3]);w=t(w,E,k,T,h,7,c[4]),T=t(T,w,E,k,f,12,c[5]),k=t(k,T,w,E,d,17,c[6]),E=t(E,k,T,w,g,22,c[7]),w=t(w,E,k,T,y,7,c[8]),T=t(T,w,E,k,v,12,c[9]),k=t(k,T,w,E,b,17,c[10]),E=t(E,k,T,w,m,22,c[11]),w=t(w,E,k,T,_,7,c[12]),T=t(T,w,E,k,O,12,c[13]),k=t(k,T,w,E,P,17,c[14]),w=n(w,E=t(E,k,T,w,S,22,c[15]),k,T,a,5,c[16]),T=n(T,w,E,k,d,9,c[17]),k=n(k,T,w,E,m,14,c[18]),E=n(E,k,T,w,u,20,c[19]),w=n(w,E,k,T,f,5,c[20]),T=n(T,w,E,k,b,9,c[21]),k=n(k,T,w,E,S,14,c[22]),E=n(E,k,T,w,h,20,c[23]),w=n(w,E,k,T,v,5,c[24]),T=n(T,w,E,k,P,9,c[25]),k=n(k,T,w,E,p,14,c[26]),E=n(E,k,T,w,y,20,c[27]),w=n(w,E,k,T,O,5,c[28]),T=n(T,w,E,k,l,9,c[29]),k=n(k,T,w,E,g,14,c[30]),w=r(w,E=n(E,k,T,w,_,20,c[31]),k,T,f,4,c[32]),T=r(T,w,E,k,y,11,c[33]),k=r(k,T,w,E,m,16,c[34]),E=r(E,k,T,w,P,23,c[35]),w=r(w,E,k,T,a,4,c[36]),T=r(T,w,E,k,h,11,c[37]),k=r(k,T,w,E,g,16,c[38]),E=r(E,k,T,w,b,23,c[39]),w=r(w,E,k,T,O,4,c[40]),T=r(T,w,E,k,u,11,c[41]),k=r(k,T,w,E,p,16,c[42]),E=r(E,k,T,w,d,23,c[43]),w=r(w,E,k,T,v,4,c[44]),T=r(T,w,E,k,_,11,c[45]),k=r(k,T,w,E,S,16,c[46]),w=i(w,E=r(E,k,T,w,l,23,c[47]),k,T,u,6,c[48]),T=i(T,w,E,k,g,10,c[49]),k=i(k,T,w,E,P,15,c[50]),E=i(E,k,T,w,f,21,c[51]),w=i(w,E,k,T,_,6,c[52]),T=i(T,w,E,k,p,10,c[53]),k=i(k,T,w,E,b,15,c[54]),E=i(E,k,T,w,a,21,c[55]),w=i(w,E,k,T,y,6,c[56]),T=i(T,w,E,k,S,10,c[57]),k=i(k,T,w,E,d,15,c[58]),E=i(E,k,T,w,O,21,c[59]),w=i(w,E,k,T,h,6,c[60]),T=i(T,w,E,k,m,10,c[61]),k=i(k,T,w,E,l,15,c[62]),E=i(E,k,T,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+E|0,s[2]=s[2]+k|0,s[3]=s[3]+T|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var g=0,y=0;for(d=0;256>d;d++){var v=(v=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&v^99;r[g]=v,i[v]=g;var b=f[g],m=f[b],_=f[m],O=257*f[v]^16843008*v;o[g]=O<<24|O>>>8,s[g]=O<<16|O>>>16,a[g]=O<<8|O>>>24,u[g]=O,O=16843009*_^65537*m^257*b^16843008*g,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,g?(g=b^f[f[f[_^b]]],y^=f[f[y]]):g=y=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],y=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=g,l=y,p=v}g=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],y=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function C(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return C(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N},M={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory"},R=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new k({timeEndpoint:o}),this._dedupingManager=new E({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s,u=e.withHeartbeat,c=void 0!==u&&u;if(o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),c){var l={};return o.forEach((function(e){return l[e]=r})),a.forEach((function(e){return l[e]=r})),this._heartbeatEndpoint({channels:o,channelGroups:a,state:l},t)}return this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===M.PNTimeoutCategory?this._startSubscribeLoop():e.category===M.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:M.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===M.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=M.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=M.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,t&&(g.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(g.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),g.action=e.payload.action,g.state=e.payload.data,g.timetoken=s.publishTimetoken,g.occupancy=e.payload.occupancy,g.uuid=e.payload.uuid,g.timestamp=e.payload.timestamp,e.payload.join&&(g.join=e.payload.join),e.payload.leave&&(g.leave=e.payload.leave),e.payload.timeout&&(g.timeout=e.payload.timeout),i._listenerManager.announcePresence(g);else if(1===e.messageType){(g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=e.payload,i._listenerManager.announceSignal(g)}else if(2===e.messageType){if((g={channel:null,subscription:null}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),g.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(g),"uuid"===e.payload.type){var a=i._renameChannelField(g);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(g);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(g)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,g.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},g.event=e.payload.event,i._listenerManager.announceMessageAction(g)}else if(4===e.messageType){(g={}).channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(g.userMetadata=e.userMetadata),g.message=f.message,g.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(g)}else{var g;(g={channel:null,subscription:null}).actualChannel=null!=o?t:null,g.subscribedChannel=null!=o?o:t,g.channel=t,g.subscription=o,g.timetoken=s.publishTimetoken,g.publisher=e.issuingClientId,e.userMetadata&&(g.userMetadata=e.userMetadata),i._config.cipherKey?g.message=i._crypto.decrypt(e.payload):g.message=e.payload,i._listenerManager.announceMessage(g)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),j={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==j.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==j.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case j.PNPublishOperation:t="pub";break;case j.PNSignalOperation:t="sig";break;case j.PNHistoryOperation:case j.PNFetchMessagesOperation:case j.PNDeleteMessagesOperation:case j.PNMessageCounts:t="hist";break;case j.PNUnsubscribeOperation:case j.PNWhereNowOperation:case j.PNHereNowOperation:case j.PNHeartbeatOperation:case j.PNSetStateOperation:case j.PNGetStateOperation:t="pres";break;case j.PNAddChannelsToGroupOperation:case j.PNRemoveChannelsFromGroupOperation:case j.PNChannelGroupsOperation:case j.PNRemoveGroupOperation:case j.PNChannelsForGroupOperation:t="cg";break;case j.PNPushNotificationEnabledChannelsOperation:case j.PNRemoveAllPushNotificationsOperation:t="push";break;case j.PNCreateUserOperation:case j.PNUpdateUserOperation:case j.PNDeleteUserOperation:case j.PNGetUserOperation:case j.PNGetUsersOperation:case j.PNCreateSpaceOperation:case j.PNUpdateSpaceOperation:case j.PNDeleteSpaceOperation:case j.PNGetSpaceOperation:case j.PNGetSpacesOperation:case j.PNGetMembersOperation:case j.PNUpdateMembersOperation:case j.PNGetMembershipsOperation:case j.PNUpdateMembershipsOperation:t="obj";break;case j.PNAddMessageActionOperation:case j.PNRemoveMessageActionOperation:case j.PNGetMessageActionsOperation:t="msga";break;case j.PNAccessManagerGrant:case j.PNAccessManagerAudit:t="pam";break;case j.PNAccessManagerGrantToken:case j.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new I(this._payload.apns,e,t),this.mpns=new D(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=M.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=M.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,g=u.length>0;return(f||d||g)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),g&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function X(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return j.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return j.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=void 0===i?{}:i,s=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),a.state=JSON.stringify(o),a.heartbeat=s.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return j.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return j.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return j.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return j.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return j.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ge={getOperation:function(){return j.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ye=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,g=e.ttl,y=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,b,m,_,O,P,S,w,T,k,E,N,C,A,M,R,j,U,x,I,D,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,b=i.form_fields,m=t.data,_=m.id,O=m.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(T=(w=l).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,T.apply(w,k.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(N=(E=l).POSTFILE,C=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,N.apply(E,C.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(M=(A=l).POSTFILE,R=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,M.apply(A,R.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(j=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(j,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(I=o.sent()).response?[4,(q=I.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw D=o.sent(),G=/(.*)<\/Message>/gi.exec(D),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",I);case 20:throw new B("Upload to bucket failed.",I);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:y,ttl:g})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},be={getOperation:function(){return j.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},me={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return j.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return j.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return j.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return j.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return j.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Te={getOperation:function(){return j.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return j.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return j.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return j.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,g={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&g.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&g.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&g.include.push("uuid")),g.include=g.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(g.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(g.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(g.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(g.filter=t.filter),g.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(g.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),g},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ce={getOperation:function(){return j.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return j.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return j.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Re=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var je=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,g=t.get,y=void 0!==g&&g,v=t.join,b=void 0!==v&&v,m=t.update,_=void 0!==m&&m,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=y?"1":"0",w.j=b?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Ie(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var De=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),g=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),y=c||l||f||p||d||h||g;return Ue(t)&&y?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Ie(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return j.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return j.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return j.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return j.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return j.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return j.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return j.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,g=void 0===d||d,y={};return y.max=s||(n.length>1||!0===o?25:100),r&&(y.start=r),i&&(y.end=i),u&&(y.string_message_token="true"),l&&(y.include_meta="true"),f&&!1!==p&&(y.include_uuid="true"),g&&(y.include_message_type="true"),y},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return j.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var Xe=Object.freeze({__proto__:null,getOperation:function(){return j.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),We={getOperation:function(){return j.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return j.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),g=d.next();!g.done;g=d.next()){var y=g.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:b,toState:p,toContext:h,event:e});try{for(var m=s(f),_=m.next();!_.done;_=m.next()){y=_.value;this.notify({type:"invocationDispatched",invocation:y})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){y=P.value;this.notify({type:"invocationDispatched",invocation:y(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(pt.type,at((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ht.type,at((function(e,n,s){var a=s.receiveEvents,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Nt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=o.sent(),[2,t.transition(kt(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Et(i))]:[3,5];case 5:return[2]}}))}))}))),r.on(ft.type,at((function(e,n,s){var a=s.handshake,u=s.shouldRetry,c=s.getRetryDelay,l=s.delay;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=o.sent(),[2,t.transition(_t(r))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(et),Mt=new Ye("STOPPED");Mt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(yt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ye("HANDSHAKE_FAILURE");Rt.onEnter((function(e){return pt({category:"PNNetworkIssuesCategory"})})),Rt.on(St.type,(function(e){return Dt.with(n(n({},e),{attempts:0}))})),Rt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Rt.on(yt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("STOPPED");jt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(yt.type,(function(e){return It.with(n({},e))}));var Ut=new Ye("RECEIVE_FAILURE");Ut.on(Ct.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),Ut.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ht(e)})),xt.onExit((function(){return ht.cancel})),xt.on(kt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),xt.on(Et.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(Nt.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[pt({category:"PNDisconnectedCategory"})])})),xt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])})),xt.on(vt.type,(function(e){return It.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(dt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}));var It=new Ye("RECEIVING");It.onEnter((function(e){return pt({category:"PNConnectedCategory"})})),It.onEnter((function(e){return ct(e.channels,e.groups,e.cursor)})),It.onExit((function(){return ct.cancel})),It.on(wt.type,(function(e,t){return It.with(n(n({},e),{cursor:t.payload.cursor}),[lt(t.payload.events)])})),It.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):It.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),It.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:"PNDisconnectedCategory"})])}));var Dt=new Ye("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ft(e)})),Dt.onExit((function(){return ft.cancel})),Dt.on(_t.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor})})),Dt.on(Ot.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(Pt.type,(function(e){return Rt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Dt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})})),Dt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return ut(e.channels,e.groups)})),Gt.onExit((function(){return ut.cancel})),Gt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(bt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:e.timetoken&&"0"!==e.timetoken?e.timetoken:t.payload.timetoken,region:t.payload.region}})})),Gt.on(mt.type,(function(e,t){return Dt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups,r=e.timetoken;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(dt(this.channels,this.groups,null!=r?r:"0"))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(yt())},e.prototype.disconnect=function(){this.engine.transition(gt())},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=function(){function e(){}return e.getDelay=function(e,t,n){var r=null!=n?n:5;switch(e.toUpperCase()){case"LINEAR":return t*r+1e3*Math.random();case"EXPONENTIAL":return 1e3*Math.trunc(Math.pow(2,t-1))+1e3*Math.random();default:throw new Error("invalid policy")}},e}(),Bt=function(){function e(e){var t,r=this,i=e.networking,o=e.cbor,c=new g({setup:e});this._config=c;var l=new T({config:c}),p=e.cryptography;i.init(c);var h=new L(c,o);this._tokenManager=h;var f=new U({maximumSamplesCount:6e4});this._telemetryManager=f;var d={config:c,networking:i,crypto:l,cryptography:p,tokenManager:h,telemetryManager:f,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,t){return p.encryptFile(e,t,r.File)},this.decryptFile=function(e,t){return p.decryptFile(e,t,r.File)};var y=X.bind(this,d,Je),v=X.bind(this,d,ie),b=X.bind(this,d,se),m=X.bind(this,d,ue),_=X.bind(this,d,Xe),O=new F;if(this._listenerManager=O,this.iAmHere=X.bind(this,d,se),this.iAmAway=X.bind(this,d,ie),this.setPresenceState=X.bind(this,d,ue),this.handshake=X.bind(this,d,We),this.receiveMessages=X.bind(this,d,$e),!0===c.enableSubscribeBeta){var P=d.config.reconnectionConfiguration.reconnectionPolicy,S=null!==(t=d.config.reconnectionConfiguration.maximumReconnectionRetries)&&void 0!==t?t:0,w=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages,getRetryDelay:function(e){return Lt.getDelay(P,e)},delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},shouldRetry:function(e,t){return S>t&&P&&"None"!=P},emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;O.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){O.announceStatus(e)}});this.subscribe=w.subscribe.bind(w),this.unsubscribe=w.unsubscribe.bind(w),this.unsubscribeAll=w.unsubscribeAll.bind(w),this.reconnect=w.reconnect.bind(w),this.disconnect=w.disconnect.bind(w),this.eventEngine=w}else{var k=new R({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:m,subscribeEndpoint:_,crypto:d.crypto,config:d.config,listenerManager:O,getFileUrl:function(e){return ve(d,e)}});this.subscribe=k.adaptSubscribeChange.bind(k),this.unsubscribe=k.adaptUnsubscribeChange.bind(k),this.disconnect=k.disconnect.bind(k),this.reconnect=k.reconnect.bind(k),this.unsubscribeAll=k.unsubscribeAll.bind(k),this.getSubscribedChannels=k.getSubscribedChannels.bind(k),this.getSubscribedChannelGroups=k.getSubscribedChannelGroups.bind(k),this.setState=k.adaptStateChange.bind(k),this.presence=k.adaptPresenceChange.bind(k),this.destroy=function(e){k.unsubscribeAll(e),k.disconnect()}}this.addListener=O.addListener.bind(O),this.removeListener=O.removeListener.bind(O),this.removeAllListeners=O.removeAllListeners.bind(O),this.parseToken=h.parseToken.bind(h),this.setToken=h.setToken.bind(h),this.getToken=h.getToken.bind(h),this.channelGroups={listGroups:X.bind(this,d,Y),listChannels:X.bind(this,d,Z),addChannels:X.bind(this,d,W),removeChannels:X.bind(this,d,$),deleteGroup:X.bind(this,d,Q)},this.push={addChannels:X.bind(this,d,ee),removeChannels:X.bind(this,d,te),deleteDevice:X.bind(this,d,re),listChannels:X.bind(this,d,ne)},this.hereNow=X.bind(this,d,ce),this.whereNow=X.bind(this,d,oe),this.getState=X.bind(this,d,ae),this.grant=X.bind(this,d,je),this.grantToken=X.bind(this,d,De),this.audit=X.bind(this,d,Re),this.revokeToken=X.bind(this,d,Ge),this.publish=X.bind(this,d,Fe),this.fire=function(e,t){return e.replicate=!1,e.storeInHistory=!1,r.publish(e,t)},this.signal=X.bind(this,d,Le),this.history=X.bind(this,d,He),this.deleteMessages=X.bind(this,d,qe),this.messageCounts=X.bind(this,d,ze),this.fetchMessages=X.bind(this,d,Ve),this.addMessageAction=X.bind(this,d,le),this.removeMessageAction=X.bind(this,d,pe),this.getMessageActions=X.bind(this,d,he),this.listFiles=X.bind(this,d,fe);var E=X.bind(this,d,de);this.publishFile=X.bind(this,d,ge),this.sendFile=ye({generateUploadUrl:E,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return ve(d,e)},this.downloadFile=X.bind(this,d,be),this.deleteFile=X.bind(this,d,me),this.objects={getAllUUIDMetadata:X.bind(this,d,_e),getUUIDMetadata:X.bind(this,d,Oe),setUUIDMetadata:X.bind(this,d,Pe),removeUUIDMetadata:X.bind(this,d,Se),getAllChannelMetadata:X.bind(this,d,we),getChannelMetadata:X.bind(this,d,Te),setChannelMetadata:X.bind(this,d,ke),removeChannelMetadata:X.bind(this,d,Ee),getChannelMembers:X.bind(this,d,Ne),setChannelMembers:function(e){for(var t=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return M.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return M.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return M.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return M.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return M.PNNetworkIssuesCategory;if(e.timeout)return M.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return M.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return M.PNBadRequestCategory;if(e.response.forbidden)return M.PNAccessDeniedCategory}return M.PNUnknownCategory},e}();function qt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?qt(s):s})),n}var zt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),Vt={exports:{}},Jt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function on(e,t,n,r){void 0===r&&(r=Zt());var i,o=sn(e,"",0,[],void 0,0,r)||e;try{i=0===Yt.length?JSON.stringify(o,t,n):JSON.stringify(o,an(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Qt.length;){var s=Qt.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function sn(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void tn(Wt,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void tn(Wt,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(dn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===hn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=gn[u]:u<2048?s+=gn[192|u>>6]+gn[128|63&u]:u<55296||u>=57344?s+=gn[224|u>>12]+gn[128|u>>6&63]+gn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=gn[240|u>>18]+gn[128|u>>12&63]+gn[128|u>>6&63]+gn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(dn(e)){for(var n=[],r=0;r0?y.join(",")||null:void 0}];else if(Pn(a))O=a;else{var S=Object.keys(y);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},In=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&Mn.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},Dn={formats:pn,parse:function(e,t){var n=function(e){if(!e)return jn;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jn.charset:e.charset;return{allowDots:void 0===e.allowDots?jn.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jn.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jn.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jn.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jn.comma,decoder:"function"==typeof e.decoder?e.decoder:jn.decoder,delimiter:"string"==typeof e.delimiter||An.isRegExp(e.delimiter)?e.delimiter:jn.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jn.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jn.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jn.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jn.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jn.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Rn(l)?[l]:l),Mn.call(r,c)?r[c]=An.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s0?p+l:""}};function Gn(e){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gn(e)}var Kn=function(e){return null!==e&&"object"===Gn(e)};function Fn(e){return Fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fn(e)}var Ln=Kn,Bn=Hn;function Hn(e){if(e)return function(e){for(var t in Hn.prototype)Object.prototype.hasOwnProperty.call(Hn.prototype,t)&&(e[t]=Hn.prototype[t]);return e}(e)}Hn.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Hn.prototype.parse=function(e){return this._parser=e,this},Hn.prototype.responseType=function(e){return this._responseType=e,this},Hn.prototype.serialize=function(e){return this._serializer=e,this},Hn.prototype.timeout=function(e){if(!e||"object"!==Fn(e))return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Hn.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var qn=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),zn=new Set([408,413,429,500,502,503,504,521,522,524]);Hn.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&zn.has(t.status))return!0;if(e){if(e.code&&qn.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Hn.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Hn.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},Hn.prototype.catch=function(e){return this.then(void 0,e)},Hn.prototype.use=function(e){return e(this),this},Hn.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Hn.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Hn.prototype.get=function(e){return this._header[e.toLowerCase()]},Hn.prototype.getHeader=Hn.prototype.get,Hn.prototype.set=function(e,t){if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Hn.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Hn.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ln(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},Hn.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},Hn.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},Hn.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Hn.prototype.redirects=function(e){return this._maxRedirects=e,this},Hn.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Hn.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Hn.prototype.send=function(e){var t=Ln(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Ln(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},Hn.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Hn.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},Hn.prototype._appendQueryString=function(){console.warn("Unsupported")},Hn.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},Hn.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var Vn={};function Jn(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function Xn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},b.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=b,i(m.prototype),a(m.prototype),m.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},m.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},m.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},m.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},m.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},m.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},m.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.ca=m.prototype.agent,m.prototype.buffer=m.prototype.ca,m.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},m.prototype.pipe=m.prototype.write,m.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},m.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},m.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},m.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(Vt,Vt.exports);var nr=Vt.exports;function rr(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function ir(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(rr)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:M.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function or(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=nr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function sr(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ar(e,t,n){var r=nr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function ur(e,t,n,r){var i=nr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function cr(e,t,n,r){var i=nr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ir.call(this,i,n,r)}function lr(e,t,n){var r=nr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ir.call(this,r,t,n)}function pr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var hr,fr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=pr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=pr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),dr=(hr=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),hr.supportsFile="undefined"!=typeof File,hr.supportsBlob="undefined"!=typeof Blob,hr.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,hr.supportsBuffer=!1,hr.supportsStream=!1,hr.supportsString=!0,hr.supportsEncryptFile=!0,hr.supportsFileUri=!1,hr);function gr(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var yr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:lr,get:ar,post:ur,patch:cr,sendBeacon:gr,getfile:sr,postfile:or}),t.cbor=new zt((function(e){return qt(p.decode(e))}),y),t.PubNubFile=dr,t.cryptography=new fr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(Bt);return yr})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 i(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=i,r.VERSION=t,e.uuid=r,e.isUUID=i}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var f=h.exports,d=function(){return f.uuid?f.uuid():f()},y=function(){function e(e){var t,n,r,i,o=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(d()),this.secretKey=o.secretKey||o.secret_key,this.subscribeKey=o.subscribeKey||o.subscribe_key,this.publishKey=o.publishKey||o.publish_key,this.sdkName=o.sdkName,this.sdkFamily=o.sdkFamily,this.partnerId=o.partnerId,this.setAuthKey(o.authKey),this.setCipherKey(o.cipherKey),this.setFilterExpression(o.filterExpression),"string"!=typeof o.origin&&!Array.isArray(o.origin)&&void 0!==o.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=o.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=o.ssl||!1,this.restore=o.restore||!1,this.proxy=o.proxy,this.keepAlive=o.keepAlive,this.keepAliveSettings=o.keepAliveSettings,this.autoNetworkDetection=o.autoNetworkDetection||!1,this.dedupeOnSubscribe=o.dedupeOnSubscribe||!1,this.maximumCacheSize=o.maximumCacheSize||100,this.customEncrypt=o.customEncrypt,this.customDecrypt=o.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=o.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=o.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=o.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(i=o.maintainPresenceState)||void 0===i||i,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=o.logVerbosity||!1,this.suppressLeaveEvents=o.suppressLeaveEvents||!1,this.announceFailedHeartbeats=o.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=o.announceSuccessfulHeartbeats||!1,this.useInstanceId=o.useInstanceId||!1,this.useRequestId=o.useRequestId||!1,this.requestMessageCountThreshold=o.requestMessageCountThreshold,o.retryConfiguration&&this.setRetryConfiguration(o.retryConfiguration),this.setTransactionTimeout(o.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(o.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(o.useSendBeacon||!0),o.presenceTimeout?this.setPresenceTimeout(o.presenceTimeout):this._presenceTimeout=300,null!=o.heartbeatInterval&&this.setHeartbeatInterval(o.heartbeatInterval),"string"==typeof o.userId){if("string"==typeof o.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(o.userId)}else{if("string"!=typeof o.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(o.uuid)}}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e){return this.cipherKey=e,this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.2.3"},e.prototype.setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function g(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),i=new Uint8Array(r),o=0;function s(){var e=t.charAt(o++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return n}for(var a=0;a>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;i[a]=h,64!=l&&(i[a+1]=f),64!=p&&(i[a+2]=d)}return r}var v,m,b,_,O,P=P||function(e,t){var n={},r=n.lib={},i=function(){},o=r.Base={extend:function(e){i.prototype=this;var t=new i;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)}},s=r.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var i=0;i>>2]|=(n[i>>>2]>>>24-i%4*8&255)<<24-(r+i)%4*8;else if(65535>>2]=n[i>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},c=a.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o);if(t=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,i=e.min(4*t,i),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(o[c]=a(e.pow(u,.5))),s[c]=a(e.pow(u,1/3)),c++),u++}var f=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(o.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+s[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&o^i&o),p=l,l=c,c=u,u=a+d|0,a=o,o=i,i=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(i),t.HmacSHA256=r._createHmacHelper(i)}(Math),m=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=m.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),s=i.words,a=o.words,u=0;u>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s>>6*(3-s)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],i=0,o=0;o>>6-o%4*2;r[i>>>2]|=(s|a)<<24-i%4*8,i++}return _.create(r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,i,o,s){return((e=e+(t&n|~t&r)+i+s)<>>32-o)+t}function n(e,t,n,r,i,o,s){return((e=e+(t&r|n&~r)+i+s)<>>32-o)+t}function r(e,t,n,r,i,o,s){return((e=e+(t^n^r)+i+s)<>>32-o)+t}function i(e,t,n,r,i,o,s){return((e=e+(n^(t|~r))+i+s)<>>32-o)+t}for(var o=P,s=(u=o.lib).WordArray,a=u.Hasher,u=o.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=a.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,o){for(var s=0;16>s;s++){var a=e[u=o+s];e[u]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}s=this._hash.words;var u=e[o+0],l=(a=e[o+1],e[o+2]),p=e[o+3],h=e[o+4],f=e[o+5],d=e[o+6],y=e[o+7],g=e[o+8],v=e[o+9],m=e[o+10],b=e[o+11],_=e[o+12],O=e[o+13],P=e[o+14],S=e[o+15],w=t(w=s[0],k=s[1],T=s[2],E=s[3],u,7,c[0]),E=t(E,w,k,T,a,12,c[1]),T=t(T,E,w,k,l,17,c[2]),k=t(k,T,E,w,p,22,c[3]);w=t(w,k,T,E,h,7,c[4]),E=t(E,w,k,T,f,12,c[5]),T=t(T,E,w,k,d,17,c[6]),k=t(k,T,E,w,y,22,c[7]),w=t(w,k,T,E,g,7,c[8]),E=t(E,w,k,T,v,12,c[9]),T=t(T,E,w,k,m,17,c[10]),k=t(k,T,E,w,b,22,c[11]),w=t(w,k,T,E,_,7,c[12]),E=t(E,w,k,T,O,12,c[13]),T=t(T,E,w,k,P,17,c[14]),w=n(w,k=t(k,T,E,w,S,22,c[15]),T,E,a,5,c[16]),E=n(E,w,k,T,d,9,c[17]),T=n(T,E,w,k,b,14,c[18]),k=n(k,T,E,w,u,20,c[19]),w=n(w,k,T,E,f,5,c[20]),E=n(E,w,k,T,m,9,c[21]),T=n(T,E,w,k,S,14,c[22]),k=n(k,T,E,w,h,20,c[23]),w=n(w,k,T,E,v,5,c[24]),E=n(E,w,k,T,P,9,c[25]),T=n(T,E,w,k,p,14,c[26]),k=n(k,T,E,w,g,20,c[27]),w=n(w,k,T,E,O,5,c[28]),E=n(E,w,k,T,l,9,c[29]),T=n(T,E,w,k,y,14,c[30]),w=r(w,k=n(k,T,E,w,_,20,c[31]),T,E,f,4,c[32]),E=r(E,w,k,T,g,11,c[33]),T=r(T,E,w,k,b,16,c[34]),k=r(k,T,E,w,P,23,c[35]),w=r(w,k,T,E,a,4,c[36]),E=r(E,w,k,T,h,11,c[37]),T=r(T,E,w,k,y,16,c[38]),k=r(k,T,E,w,m,23,c[39]),w=r(w,k,T,E,O,4,c[40]),E=r(E,w,k,T,u,11,c[41]),T=r(T,E,w,k,p,16,c[42]),k=r(k,T,E,w,d,23,c[43]),w=r(w,k,T,E,v,4,c[44]),E=r(E,w,k,T,_,11,c[45]),T=r(T,E,w,k,S,16,c[46]),w=i(w,k=r(k,T,E,w,l,23,c[47]),T,E,u,6,c[48]),E=i(E,w,k,T,y,10,c[49]),T=i(T,E,w,k,P,15,c[50]),k=i(k,T,E,w,f,21,c[51]),w=i(w,k,T,E,_,6,c[52]),E=i(E,w,k,T,p,10,c[53]),T=i(T,E,w,k,m,15,c[54]),k=i(k,T,E,w,a,21,c[55]),w=i(w,k,T,E,g,6,c[56]),E=i(E,w,k,T,S,10,c[57]),T=i(T,E,w,k,d,15,c[58]),k=i(k,T,E,w,O,21,c[59]),w=i(w,k,T,E,h,6,c[60]),E=i(E,w,k,T,b,10,c[61]),T=i(T,E,w,k,l,15,c[62]),k=i(k,T,E,w,v,21,c[63]);s[0]=s[0]+w|0,s[1]=s[1]+k|0,s[2]=s[2]+T|0,s[3]=s[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var e=a.clone.call(this);return e._hash=this._hash.clone(),e}}),o.MD5=a._createHelper(u),o.HmacMD5=a._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,i=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(a=this.cfg).hasher.create(),i=r.create(),o=i.words,s=a.keySize,a=a.iterations;o.length>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:u,padding:l}),reset:function(){a.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(o)},parse:function(e){var t=(e=o.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r);return t=i.finalize(t),i=i.cfg,p.create({ciphertext:t,key:n,iv:i.iv,algorithm:e,mode:i.mode,padding:i.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,i){return i||(i=r.random(8)),e=s.create({keySize:t+n}).compute(e,i),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:i})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],i=[],o=[],s=[],a=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var v=(v=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&v^99;r[y]=v,i[v]=y;var m=f[y],b=f[m],_=f[b],O=257*f[v]^16843008*v;o[y]=O<<24|O>>>8,s[y]=O<<16|O>>>16,a[y]=O<<8|O>>>24,u[y]=O,O=16843009*_^65537*b^257*m^16843008*y,c[v]=O<<24|O>>>8,l[v]=O<<16|O>>>16,p[v]=O<<8|O>>>24,h[v]=O,y?(y=m^f[f[f[_^m]]],g^=f[f[g]]):y=g=1}var S=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),i=this._keySchedule=[],o=0;o>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s]):(s=r[(s=s<<8|s>>>24)>>>24]<<24|r[s>>>16&255]<<16|r[s>>>8&255]<<8|r[255&s],s^=S[o/t|0]<<24),i[o]=i[o-t]^s}for(e=this._invKeySchedule=[],t=0;tt||4>=o?s:c[r[s>>>24]]^l[r[s>>>16&255]]^p[r[s>>>8&255]]^h[r[255&s]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,o,s,a,u,r)},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,c,l,p,h,i),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^i[l>>>16&255]^o[p>>>8&255]^s[255&h]^n[f++],g=r[l>>>24]^i[p>>>16&255]^o[h>>>8&255]^s[255&c]^n[f++],v=r[p>>>24]^i[h>>>16&255]^o[c>>>8&255]^s[255&l]^n[f++];h=r[h>>>24]^i[c>>>16&255]^o[l>>>8&255]^s[255&p]^n[f++],c=y,l=g,p=v}y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&h])^n[f++],g=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[h>>>8&255]<<8|a[255&c])^n[f++],v=(a[p>>>24]<<24|a[h>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^n[f++],h=(a[h>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=v,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var S=P;function w(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function C(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function N(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var A={signPamFromParams:function(e){return N(e).map((function(t){return"".concat(t,"=").concat(C(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:C},R={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory",PNConnectionErrorCategory:"PNConnectionErrorCategory",PNDisconnectedUnexpectedlyCategory:"PNDisconnectedUnexpectedlyCategory"},M=function(){function e(e){var t=e.subscribeEndpoint,n=e.leaveEndpoint,r=e.heartbeatEndpoint,i=e.setStateEndpoint,o=e.timeEndpoint,s=e.getFileUrl,a=e.config,u=e.crypto,c=e.listenerManager;this._listenerManager=c,this._config=a,this._leaveEndpoint=n,this._heartbeatEndpoint=r,this._setStateEndpoint=i,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new T({timeEndpoint:o}),this._dedupingManager=new k({config:a})}return e.prototype.adaptStateChange=function(e,t){var n=this,r=e.state,i=e.channels,o=void 0===i?[]:i,s=e.channelGroups,a=void 0===s?[]:s,u=e.withHeartbeat,c=void 0!==u&&u;if(o.forEach((function(e){e in n._channels&&(n._channels[e].state=r)})),a.forEach((function(e){e in n._channelGroups&&(n._channelGroups[e].state=r)})),c){var l={};return o.forEach((function(e){return l[e]=r})),a.forEach((function(e){return l[e]=r})),this._heartbeatEndpoint({channels:o,channelGroups:a,state:l},t)}return this._setStateEndpoint({state:r,channels:o,channelGroups:a},t)},e.prototype.adaptPresenceChange=function(e){var t=this,n=e.connected,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o;n?(i.forEach((function(e){t._heartbeatChannels[e]={state:{}}})),s.forEach((function(e){t._heartbeatChannelGroups[e]={state:{}}}))):(i.forEach((function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]})),s.forEach((function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]})),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:i,channelGroups:s},(function(e){t._listenerManager.announceStatus(e)}))),this.reconnect()},e.prototype.adaptSubscribeChange=function(e){var t=this,n=e.timetoken,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=e.withPresence,u=void 0!==a&&a,c=e.withHeartbeats,l=void 0!==c&&c;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),i.forEach((function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)})),s.forEach((function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),(l||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)})),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},e.prototype.adaptUnsubscribeChange=function(e,t){var n=this,r=e.channels,i=void 0===r?[]:r,o=e.channelGroups,s=void 0===o?[]:o,a=[],u=[];i.forEach((function(e){e in n._channels&&(delete n._channels[e],a.push(e),e in n._heartbeatChannels&&delete n._heartbeatChannels[e]),e in n._presenceChannels&&(delete n._presenceChannels[e],a.push(e))})),s.forEach((function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e),e in n._heartbeatChannelGroups&&delete n._heartbeatChannelGroups[e]),e in n._presenceChannelGroups&&(delete n._presenceChannelGroups[e],u.push(e))})),0===a.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:a,channelGroups:u},(function(e){e.affectedChannels=a,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)})),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())},e.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},e.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},e.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},e.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},e.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},e.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},e.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},e.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},e.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},e.prototype._performHeartbeatLoop=function(){var e=this,t=this.getHeartbeatChannels(),n=this.getHeartbeatChannelGroups(),r={};if(0!==t.length||0!==n.length){this.getSubscribedChannels().forEach((function(t){var n=e._channels[t].state;Object.keys(n).length&&(r[t]=n)})),this.getSubscribedChannelGroups().forEach((function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(r[t]=n)}));this._heartbeatEndpoint({channels:t,channelGroups:n,state:r},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this))}},e.prototype._startSubscribeLoop=function(){var e=this;this._stopSubscribeLoop();var t={},n=[],r=[];if(Object.keys(this._channels).forEach((function(r){var i=e._channels[r].state;Object.keys(i).length&&(t[r]=i),n.push(r)})),Object.keys(this._presenceChannels).forEach((function(e){n.push("".concat(e,"-pnpres"))})),Object.keys(this._channelGroups).forEach((function(n){var i=e._channelGroups[n].state;Object.keys(i).length&&(t[n]=i),r.push(n)})),Object.keys(this._presenceChannelGroups).forEach((function(e){r.push("".concat(e,"-pnpres"))})),0!==n.length||0!==r.length){var i={channels:n,channelGroups:r,state:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(i,this._processSubscribeResponse.bind(this))}},e.prototype._processSubscribeResponse=function(e,t){var i=this;if(e.error){if(e.errorData&&"Aborted"===e.errorData.message)return;e.category===R.PNTimeoutCategory?this._startSubscribeLoop():e.category===R.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection((function(){i._config.autoNetworkDetection&&!i._isOnline&&(i._isOnline=!0,i._listenerManager.announceNetworkUp()),i.reconnect(),i._subscriptionStatusAnnounced=!0;var t={category:R.PNReconnectedCategory,operation:e.operation,lastTimetoken:i._lastTimetoken,currentTimetoken:i._currentTimetoken};i._listenerManager.announceStatus(t)})),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===R.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var o={};o.category=R.PNConnectedCategory,o.operation=e.operation,o.affectedChannels=this._pendingChannelSubscriptions,o.subscribedChannels=this.getSubscribedChannels(),o.affectedChannelGroups=this._pendingChannelGroupSubscriptions,o.lastTimetoken=this._lastTimetoken,o.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(o),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var s=t.messages||[],a=this._config,u=a.requestMessageCountThreshold,c=a.dedupeOnSubscribe;if(u&&s.length>=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}s.forEach((function(e){var t=e.channel,o=e.subscriptionMatch,s=e.publishMetaData;if(t===o&&(o=null),c){if(i._dedupingManager.isDuplicate(e))return;i._dedupingManager.addEntry(e)}if(A.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=o?t:null,y.subscribedChannel=null!=o?o:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),o&&(y.subscription=o.substring(0,o.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=s.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),i._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=o,y.timetoken=s.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,i._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=o,y.timetoken=s.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},i._listenerManager.announceObjects(y),"uuid"===e.payload.type){var a=i._renameChannelField(y);i._listenerManager.announceUser(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"user"})}))}else if("channel"===e.payload.type){a=i._renameChannelField(y);i._listenerManager.announceSpace(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(a=i._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,i._listenerManager.announceMembership(n(n({},a),{message:n(n({},a.message),{event:i._renameEvent(a.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=o,y.timetoken=s.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,i._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=o,y.timetoken=s.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(i._config.cipherKey){var d=i._crypto.decrypt(e.payload);"object"==typeof d&&null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:i._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},i._listenerManager.announceFile(y)}else{var y;(y={channel:null,subscription:null}).actualChannel=null!=o?t:null,y.subscribedChannel=null!=o?o:t,y.channel=t,y.subscription=o,y.timetoken=s.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),i._config.cipherKey?y.message=i._crypto.decrypt(e.payload):y.message=e.payload,i._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),j={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},U=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],i=e._averageLatency(r);i>0&&(t["l_".concat(n)]=i)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==j.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==j.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],i=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-i),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case j.PNPublishOperation:t="pub";break;case j.PNSignalOperation:t="sig";break;case j.PNHistoryOperation:case j.PNFetchMessagesOperation:case j.PNDeleteMessagesOperation:case j.PNMessageCounts:t="hist";break;case j.PNUnsubscribeOperation:case j.PNWhereNowOperation:case j.PNHereNowOperation:case j.PNHeartbeatOperation:case j.PNSetStateOperation:case j.PNGetStateOperation:t="pres";break;case j.PNAddChannelsToGroupOperation:case j.PNRemoveChannelsFromGroupOperation:case j.PNChannelGroupsOperation:case j.PNRemoveGroupOperation:case j.PNChannelsForGroupOperation:t="cg";break;case j.PNPushNotificationEnabledChannelsOperation:case j.PNRemoveAllPushNotificationsOperation:t="push";break;case j.PNCreateUserOperation:case j.PNUpdateUserOperation:case j.PNDeleteUserOperation:case j.PNGetUserOperation:case j.PNGetUsersOperation:case j.PNCreateSpaceOperation:case j.PNUpdateSpaceOperation:case j.PNDeleteSpaceOperation:case j.PNGetSpaceOperation:case j.PNGetSpacesOperation:case j.PNGetMembersOperation:case j.PNUpdateMembersOperation:case j.PNGetMembershipsOperation:case j.PNUpdateMembershipsOperation:t="obj";break;case j.PNAddMessageActionOperation:case j.PNRemoveMessageActionOperation:case j.PNGetMessageActionsOperation:t="msga";break;case j.PNAccessManagerGrant:case j.PNAccessManagerAudit:t="pam";break;case j.PNAccessManagerGrantToken:case j.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),x=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),D=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,i=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach((function(t){o.push(e._objectFromAPNS2Configuration(t))})),o.length&&(t.pn_push=o)}return i&&Object.keys(i).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,i={}),this._isSilent||Object.keys(i).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,i=e.expirationDate,o={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(o.collapse_id=r),i&&(o.expiration=i.toISOString()),o},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,i=e.excludedDevices,o=void 0===i?[]:i,s={topic:t,environment:r};return o.length&&(s.excluded_devices=o),s},r}(x),I=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(x),G=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t(i,e),Object.defineProperty(i.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),i.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},i.prototype.toObject=function(){var e=n({},this._payload.data),t=null,i={};if(Object.keys(this._payload).length>2){var o=this._payload;o.notification,o.data;var s=r(o,["notification","data"]);e=n(n({},e),s)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(i.data=e),t&&Object.keys(t).length&&(i.notification=t),Object.keys(i).length?i:null},i}(x),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new D(this._payload.apns,e,t),this.mpns=new I(this._payload.mpns,e,t),this.fcm=new G(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var i=this.fcm.toObject();i&&Object.keys(i).length&&(t.pn_gcm=i)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),F=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),L=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],i=Object.keys(n.res.chan),o=Object.keys(n.res.grp),s=n.pat.uuid?Object.keys(n.pat.uuid):[],a=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=i.length>0,h=o.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},i.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},o.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=s.length>0,d=a.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},s.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},a.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),B=function(e){function n(t,n){var r=this.constructor,i=e.call(this,t)||this;return i.name=i.constructor.name,i.status=n,i.message=t,Object.setPrototypeOf(i,r.prototype),i}return t(n,e),n}(Error);function H(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function q(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function z(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function V(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function J(e,t,n,r,i){var o=e.config,s=e.crypto,a=V(e,i,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===i.getOperation()&&i.usePost&&i.usePost(e,r)&&(a="GET"),"GETFILE"===a&&(a="GET");var u="".concat(a,"\n").concat(o.publishKey,"\n").concat(t,"\n").concat(A.signPamFromParams(n),"\n");if("POST"===a)u+="string"==typeof(c=i.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===a){var c;u+="string"==typeof(c=i.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(s.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function W(e,t){for(var r=[],i=2;i0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(){return{}}});var oe=Object.freeze({__proto__:null,getOperation:function(){return j.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var se=Object.freeze({__proto__:null,getOperation:function(){return j.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i=t.state,o=e.config,s={};return r.length>0&&(s["channel-group"]=r.join(",")),i&&(s.state=JSON.stringify(i)),s.heartbeat=o.getPresenceTimeout(),s},handleResponse:function(){return{}}});var ae=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,i=void 0===r?n.UUID:r,o=t.channels,s=void 0===o?[]:o,a=s.length>0?s.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(a),"/uuid/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,i={};return r.length>0&&(i["channel-group"]=r.join(",")),i},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a={};return 1===i.length&&0===s.length?a[i[0]]=t.payload:a=t.payload,{channels:a}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return j.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,i=t.channels,o=void 0===i?[]:i,s=t.channelGroups,a=void 0===s?[]:s;return r?n.subscribeKey?0===o.length&&0===a.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(o),"/uuid/").concat(A.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,i=void 0===r?[]:r,o={};return o.state=JSON.stringify(n),i.length>0&&(o["channel-group"]=i.join(",")),o},handleResponse:function(e,t){return{state:t.payload}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return j.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=t.channelGroups,s=void 0===o?[]:o,a="/v2/presence/sub-key/".concat(n.subscribeKey);if(i.length>0||s.length>0){var u=i.length>0?i.join(","):",";a+="/channel/".concat(A.encodeString(u))}return a},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,i=void 0===r?[]:r,o=t.includeUUIDs,s=void 0===o||o,a=t.includeState,u=void 0!==a&&a,c=t.queryParameters,l=void 0===c?{}:c,p={};return s||(p.disable_uuids=1),u&&(p.state=1),i.length>0&&(p["channel-group"]=i.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,i=void 0===r?[]:r,o=n.channelGroups,s=void 0===o?[]:o,a=n.includeUUIDs,u=void 0===a||a,c=n.includeState,l=void 0!==c&&c;return i.length>1||s.length>0||0===s.length&&0===i.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],i=[];return e.channels[n]={occupants:i,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?i.push({state:e.state,uuid:e.uuid}):i.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[i[0]]={occupants:n,name:i[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var le=Object.freeze({__proto__:null,getOperation:function(){return j.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,i=t.channel;return t.messageTimetoken?n.subscribeKey?i?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return j.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken;return t.messageTimetoken?i?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,i=t.actionTimetoken,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r),"/message/").concat(o,"/action/").concat(i)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return j.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(A.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,i=t.end,o={};return n&&(o.limit=n),r&&(o.start=r),i&&(o.end=i),o},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),fe={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},de={getOperation:function(){return j.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ye={getOperation:function(){return j.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,i=n.subscribeKey,o=function(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(i,"/0/").concat(A.encodeString(t.channel),"/0/").concat(A.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ge=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,s=e.modules,a=s.PubNubFile,u=s.config,c=s.cryptography,l=s.networking;return function(e){var s=e.channel,p=e.file,h=e.message,f=e.cipherKey,d=e.meta,y=e.ttl,g=e.storeInHistory;return i(t,void 0,void 0,(function(){var e,t,i,v,m,b,_,O,P,S,w,E,T,k,C,N,A,R,M,j,U,x,D,I,G,K,F,L;return o(this,(function(o){switch(o.label){case 0:if(!s)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!p)throw new B("Validation failed, check status for details",H("file can't be empty"));return e=a.create(p),[4,n({channel:s,name:e.name})];case 1:return t=o.sent(),i=t.file_upload_request,v=i.url,m=i.form_fields,b=t.data,_=b.id,O=b.name,a.supportsEncryptFile&&(null!=f?f:u.cipherKey)?[4,c.encryptFile(null!=f?f:u.cipherKey,e,a)]:[3,3];case 2:e=o.sent(),o.label=3;case 3:P=m,e.mimeType&&(P=m.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),o.label=4;case 4:return o.trys.push([4,18,,22]),a.supportsFileUri&&p.uri?(E=(w=l).POSTFILE,T=[v,P],[4,e.toFileUri()]):[3,7];case 5:return[4,E.apply(w,T.concat([o.sent()]))];case 6:return S=o.sent(),[3,17];case 7:return a.supportsFile?(C=(k=l).POSTFILE,N=[v,P],[4,e.toFile()]):[3,10];case 8:return[4,C.apply(k,N.concat([o.sent()]))];case 9:return S=o.sent(),[3,17];case 10:return a.supportsBuffer?(R=(A=l).POSTFILE,M=[v,P],[4,e.toBuffer()]):[3,13];case 11:return[4,R.apply(A,M.concat([o.sent()]))];case 12:return S=o.sent(),[3,17];case 13:return a.supportsBlob?(U=(j=l).POSTFILE,x=[v,P],[4,e.toBlob()]):[3,16];case 14:return[4,U.apply(j,x.concat([o.sent()]))];case 15:return S=o.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(D=o.sent()).response?[4,(q=D.response,new Promise((function(e){var t="";q.on("data",(function(e){t+=e.toString("utf8")})),q.on("end",(function(){e(t)}))})))]:[3,20];case 19:throw I=o.sent(),G=/(.*)<\/Message>/gi.exec(I),new B(G?"Upload to bucket failed: ".concat(G[1]):"Upload to bucket failed.",D);case 20:throw new B("Upload to bucket failed.",D);case 21:return[3,22];case 22:if(204!==S.status)throw new B("Upload to bucket was unsuccessful",S);K=u.fileUploadPublishRetryLimit,F=!1,L={timetoken:"0"},o.label=23;case 23:return o.trys.push([23,25,,26]),[4,r({channel:s,message:h,fileId:_,fileName:O,meta:d,storeInHistory:g,ttl:y})];case 24:return L=o.sent(),F=!0,[3,26];case 25:return o.sent(),K-=1,[3,26];case 26:if(!F&&K>0)return[3,23];o.label=27;case 27:if(F)return[2,{timetoken:L.timetoken,id:_,name:O}];throw new B("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:s,id:_,name:O})}var q}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,i=t.name,o=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new B("Validation failed, check status for details",H("channel can't be empty"));if(!r)throw new B("Validation failed, check status for details",H("file id can't be empty"));if(!i)throw new B("Validation failed, check status for details",H("file name can't be empty"));var u="/v1/files/".concat(o.subscribeKey,"/channels/").concat(A.encodeString(n),"/files/").concat(r,"/").concat(i),c={};c.uuid=o.getUUID(),c.pnsdk=z(o);var l=a.getToken()||o.getAuthKey();l&&(c.auth=l),o.secretKey&&J(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(s.getStandardOrigin()).concat(u,"?").concat(p):"".concat(s.getStandardOrigin()).concat(u)},me={getOperation:function(){return j.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,s=e.config,a=e.cryptography;return i(void 0,void 0,void 0,(function(){var e,i,u,c;return o(this,(function(o){switch(o.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(null!==(i=n.cipherKey)&&void 0!==i?i:s.cipherKey)?[4,a.decrypt(null!==(u=n.cipherKey)&&void 0!==u?u:s.cipherKey,e)]:[3,2];case 1:e=o.sent(),o.label=2;case 2:return[2,r.create({data:e,name:null!==(c=t.response.name)&&void 0!==c?c:n.name,mimeType:t.response.type})]}}))}))}},be={getOperation:function(){return j.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},_e={getOperation:function(){return j.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return j.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return j.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i=e.config,o={};return o.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:i.getUUID(),o.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&o.include.pop(),o.include=o.include.join(","),o},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Se={getOperation:function(){return j.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return j.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(i=t.include)||void 0===i?void 0:i.totalCount),(null===(o=null==t?void 0:t.page)||void 0===o?void 0:o.next)&&(h.start=null===(s=t.page)||void 0===s?void 0:s.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ee={getOperation:function(){return j.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return j.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return j.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return j.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"UUID cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d,y={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&y.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&y.include.push("uuid.custom"),(null===(o=null===(i=t.include)||void 0===i?void 0:i.UUIDFields)||void 0===o||o)&&y.include.push("uuid")),y.include=y.include.join(","),(null===(s=null==t?void 0:t.include)||void 0===s?void 0:s.totalCount)&&(y.count=null===(u=t.include)||void 0===u?void 0:u.totalCount),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.next)&&(y.start=null===(l=t.page)||void 0===l?void 0:l.next),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.prev)&&(y.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(y.filter=t.filter),y.limit=null!==(f=null==t?void 0:t.limit)&&void 0!==f?f:100,(null==t?void 0:t.sort)&&(y.sort=Object.entries(null!==(d=t.sort)&&void 0!==d?d:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),y},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ne={getOperation:function(){return j.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(A.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(i=t.include)||void 0===i?void 0:i.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return j.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h,f,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(d.count=null===(s=t.include)||void 0===s?void 0:s.totalCount),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.next)&&(d.start=null===(c=t.page)||void 0===c?void 0:c.next),(null===(l=null==t?void 0:t.page)||void 0===l?void 0:l.prev)&&(d.end=null===(p=t.page)||void 0===p?void 0:p.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(h=null==t?void 0:t.limit)&&void 0!==h?h:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(f=t.sort)&&void 0!==f?f:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return j.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(A.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,i,o,s,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(i=t.include)||void 0===i?void 0:i.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(o=null==t?void 0:t.include)||void 0===o?void 0:o.totalCount)&&(h.count=!0),(null===(s=null==t?void 0:t.page)||void 0===s?void 0:s.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=a(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Me=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,i=t.authKeys,o=void 0===i?[]:i,s={};return n&&(s.channel=n),r&&(s["channel-group"]=r),o.length>0&&(s.auth=o.join(",")),s},handleResponse:function(e,t){return t.payload}});var je=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.channelGroups,o=void 0===i?[]:i,s=t.uuids,a=void 0===s?[]:s,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,v=t.join,m=void 0!==v&&v,b=t.update,_=void 0!==b&&b,O=t.authKeys,P=void 0===O?[]:O,S=t.delete,w={};return w.r=l?"1":"0",w.w=h?"1":"0",w.m=d?"1":"0",w.d=S?"1":"0",w.g=g?"1":"0",w.j=m?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),o.length>0&&(w["channel-group"]=o.join(",")),P.length>0&&(w.auth=P.join(",")),a.length>0&&(w["target-uuid"]=a.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function Ue(e){var t,n,r,i,o=void 0!==(null==e?void 0:e.authorizedUserId),s=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),a=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(i=null==e?void 0:e.patterns)||void 0===i?void 0:i.spaces);return u||s||c||a||o}function xe(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function De(e,t){if(Ue(t))return function(e,t){var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorizedUserId,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.users,h=i.spaces,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}(0,t);var n=t.ttl,r=t.resources,i=t.patterns,o=t.meta,s=t.authorized_uuid,a={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){a.permissions.resources.uuids[e]=xe(u[e])})),c&&Object.keys(c).forEach((function(e){a.permissions.resources.channels[e]=xe(c[e])})),l&&Object.keys(l).forEach((function(e){a.permissions.resources.groups[e]=xe(l[e])}))}if(i){var p=i.uuids,h=i.channels,f=i.groups;p&&Object.keys(p).forEach((function(e){a.permissions.patterns.uuids[e]=xe(p[e])})),h&&Object.keys(h).forEach((function(e){a.permissions.patterns.channels[e]=xe(h[e])})),f&&Object.keys(f).forEach((function(e){a.permissions.patterns.groups[e]=xe(f[e])}))}return(n||0===n)&&(a.ttl=n),o&&(a.permissions.meta=o),s&&(a.permissions.uuid="".concat(s)),a}var Ie=Object.freeze({__proto__:null,getOperation:function(){return j.PNAccessManagerGrantToken},extractPermissions:xe,validateParams:function(e,t){var n,r,i,o,s,a,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(i=null==t?void 0:t.resources)||void 0===i?void 0:i.groups),f=void 0!==(null===(o=null==t?void 0:t.patterns)||void 0===o?void 0:o.uuids),d=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.channels),y=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.groups),g=c||l||f||p||d||h||y;return Ue(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return De(0,t)},handleResponse:function(e,t){return t.data.token}}),Ge={getOperation:function(){return j.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(A.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=e.crypto,r=e.config,i=JSON.stringify(t);return r.cipherKey&&(i=n.encrypt(i),i=JSON.stringify(i)),i}var Fe=Object.freeze({__proto__:null,getOperation:function(){return j.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,i=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0/").concat(A.encodeString(i))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,i=void 0===r||r,o=t.storeInHistory,s=t.ttl,a={};return null!=o&&(a.store=o?"1":"0"),s&&(a.ttl=s),!1===i&&(a.norep="true"),n&&"object"==typeof n&&(a.meta=JSON.stringify(n)),a},handleResponse:function(e,t){return{timetoken:t[2]}}});var Le=Object.freeze({__proto__:null,getOperation:function(){return j.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,i=t.channel,o=t.message,s=(n=o,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(A.encodeString(i),"/0/").concat(A.encodeString(s))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});function Be(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}var He=Object.freeze({__proto__:null,getOperation:function(){return j.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i=t.reverse,o=t.count,s=void 0===o?100:o,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=s,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=i&&(p.reverse=i.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r={timetoken:t.timetoken,entry:Be(e,t.message)};t.meta&&(r.meta=t.meta),n.messages.push(r)})),n}});var qe=Object.freeze({__proto__:null,getOperation:function(){return j.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(A.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,i={};return n&&(i.start=n),r&&(i.end=r),i},handleResponse:function(e,t){return t.payload}});var ze=Object.freeze({__proto__:null,getOperation:function(){return j.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,i=t.channelTimetokens,o=e.config;return n?r&&i?"timetoken and channelTimetokens are incompatible together":r&&i&&i.length>1&&n.length!==i.length?"Length of channelTimetokens and channels do not match":o.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,i=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(A.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,i={};if(r&&1===r.length){var o=a(r,1)[0];i.timetoken=o}else r?i.channelsTimetoken=r.join(","):n&&(i.timetoken=n);return i},handleResponse:function(e,t){return{channels:t.channels}}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return j.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,i=void 0!==r&&r,o=e.config;if(!n||0===n.length)return"Missing channels";if(!o.subscribeKey)return"Missing Subscribe Key";if(i&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,i=t.includeMessageActions,o=void 0!==i&&i,s=e.config,a=o?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(a,"/sub-key/").concat(s.subscribeKey,"/channel/").concat(A.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,i=t.end,o=t.includeMessageActions,s=t.count,a=t.stringifiedTimeToken,u=void 0!==a&&a,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=s||(n.length>1||!0===o?25:100),r&&(g.start=r),i&&(g.end=i),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var i={};i.channel=r,i.timetoken=t.timetoken,i.message=function(e,t){var n=e.config,r=e.crypto;if(!n.cipherKey)return t;try{return r.decrypt(t)}catch(e){return t}}(e,t.message),i.messageType=t.message_type,i.uuid=t.uuid,t.actions&&(i.actions=t.actions,i.data=t.actions),t.meta&&(i.meta=t.meta),n.channels[r].push(i)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return j.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var We=Object.freeze({__proto__:null,getOperation:function(){return j.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,i=void 0===r?[]:r,o=i.length>0?i.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(o),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,i=t.channelGroups,o=void 0===i?[]:i,s=t.timetoken,a=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return o.length>0&&(c["channel-group"]=o.join(",")),a&&a.length>0&&(c["filter-expr"]=a),Object.keys(r).length&&(c.state=JSON.stringify(r)),s&&(c.tt=s),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Xe={getOperation:function(){return j.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},$e={getOperation:function(){return j.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(A.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Qe=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ye=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),Ze=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ye(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,i,o,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=a(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=s(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var m=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:v,fromContext:m,toState:p,toContext:h,event:e});try{for(var b=s(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=b.return)&&i.call(b)}finally{if(r)throw r.error}}try{for(var O=s(this.currentState.enterEffects),P=O.next();!P.done;P=O.next()){g=P.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){o={error:e}}finally{try{P&&!P.done&&(u=O.return)&&u.call(O)}finally{if(o)throw o.error}}}},n}(Qe),et=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=s(this.instances.entries()),r=n.next();!r.done;r=n.next()){var i=a(r.value,2),o=i[0];i[1].cancel(),this.instances.delete(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function tt(e,t){var n=function(){for(var n=[],r=0;r0&&s(e),[2]}))}))}))),r.on(pt.type,at((function(e,t,n){var s=n.emitStatus;return i(r,void 0,void 0,(function(){return o(this,(function(t){return s(e),[2]}))}))}))),r.on(ht.type,at((function(e,n,s){var a=s.receiveEvents,u=s.delay,c=s.config;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=o.sent(),[2,t.transition(Et(r.metadata,r.messages))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Tt(i))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(kt())];case 7:return[2]}}))}))}))),r.on(ft.type,at((function(e,n,s){var a=s.handshake,u=s.delay,c=s.presenceState,l=s.config;return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,a({abortSignal:n,channels:e.channels,channelGroups:e.groups,filterExpression:l.filterExpression,state:c})];case 3:return r=o.sent(),[2,t.transition(_t(r))];case 4:return(i=o.sent())instanceof Error&&"Aborted"===i.message?[2]:i instanceof B?[2,t.transition(Ot(i))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Pt())];case 7:return[2]}}))}))}))),r}return t(n,e),n}(et),Rt=new Ye("HANDSHAKE_STOPPED");Rt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e){return Gt.with(n({},e))}));var Mt=new Ye("HANDSHAKE_FAILURE");Mt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups})})),Mt.on(gt.type,(function(e){return Gt.with(n({},e))}));var jt=new Ye("STOPPED");jt.on(dt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(vt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(gt.type,(function(e){return Gt.with({channels:e.channels,groups:e.groups})})),jt.on(Nt.type,(function(){return Kt.with(void 0)}));var Ut=new Ye("RECEIVE_FAILED");Ut.on(Ct.type,(function(e){return Gt.with({channels:e.channels,groups:e.groups,timetoken:e.cursor.timetoken})})),Ut.on(yt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ut.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),Ut.on(vt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),Ut.on(Nt.type,(function(e){return Kt.with(void 0)}));var xt=new Ye("RECEIVE_RECONNECTING");xt.onEnter((function(e){return ht(e)})),xt.onExit((function(){return ht.cancel})),xt.on(Et.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),xt.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(kt.type,(function(e){return Ut.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[pt({category:R.PNDisconnectedUnexpectedlyCategory})])})),xt.on(yt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:R.PNDisconnectedCategory})])})),xt.on(vt.type,(function(e,t){var n,r;return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:null!==(n=t.payload.timetoken)&&void 0!==n?n:e.cursor.timetoken,region:null!==(r=t.payload.region)&&void 0!==r?r:e.cursor.region}})})),xt.on(dt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(Nt.type,(function(e){return Kt.with(void 0,[pt({category:R.PNDisconnectedCategory})])}));var Dt=new Ye("RECEIVING");Dt.onEnter((function(e){return ct(e.channels,e.groups,e.cursor)})),Dt.onExit((function(){return ct.cancel})),Dt.on(St.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[lt(t.payload.events)])})),Dt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Dt.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(wt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Dt.on(yt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[pt({category:R.PNDisconnectedCategory})])})),Dt.on(Nt.type,(function(e){return Kt.with(void 0,[pt({category:R.PNDisconnectedCategory})])}));var It=new Ye("HANDSHAKE_RECONNECTING");It.onEnter((function(e){return ft(e)})),It.onExit((function(){return ft.cancel})),It.on(_t.type,(function(e,t){var n=e.timetoken?{timetoken:e.timetoken,region:1}:t.payload.cursor;return Dt.with({channels:e.channels,groups:e.groups,cursor:n},[pt({category:R.PNConnectedCategory})])})),It.on(Ot.type,(function(e,t){return It.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),It.on(Pt.type,(function(e){return Mt.with({groups:e.groups,channels:e.channels,reason:e.reason},[pt({category:R.PNConnectionErrorCategory})])})),It.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups},[pt({category:R.PNDisconnectedCategory})])})),It.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),It.on(vt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),It.on(Nt.type,(function(e){return Kt.with(void 0,[pt({category:R.PNDisconnectedCategory})])}));var Gt=new Ye("HANDSHAKING");Gt.onEnter((function(e){return ut(e.channels,e.groups)})),Gt.onExit((function(){return ut.cancel})),Gt.on(dt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Kt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(mt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:{timetoken:e.timetoken&&"0"!==e.timetoken?e.timetoken:t.payload.timetoken,region:t.payload.region}},[pt({category:R.PNConnectedCategory})])})),Gt.on(bt.type,(function(e,t){return It.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(yt.type,(function(e){return Rt.with({channels:e.channels,groups:e.groups})})),Gt.on(Nt.type,(function(e){return Kt.with()})),Gt.on(vt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Kt=new Ye("UNSUBSCRIBED");Kt.on(dt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),Kt.on(vt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Ft=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new At(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Kt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,i=e.timetoken,o=e.withPresence;this.channels=u(u([],a(this.channels),!1),a(null!=n?n:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=r?r:[]),!1),o&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),i?this.engine.transition(vt(this.channels,this.groups,i)):this.engine.transition(dt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,i=null==n?void 0:n.slice(0);null==n||n.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==i?void 0:i.includes(e))}));var o=null==r?void 0:r.slice(0);null==r||r.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==o?void 0:o.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(dt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(){this.engine.transition(gt())},e.prototype.disconnect=function(){this.engine.transition(yt()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Lt=tt("RECONNECT",(function(){return{}})),Bt=tt("DISCONNECT",(function(){return{}})),Ht=tt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=tt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=tt("LEFT_ALL",(function(){return{}})),Vt=tt("HEARTBEAT_SUCCESS",(function(){return{}})),Jt=tt("HEARTBEAT_FAILURE",(function(e){return e})),Wt=tt("HEARTBEAT_GIVEUP",(function(){return{}})),Xt=tt("TIMES_UP",(function(){return{}})),$t=nt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Qt=nt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("WAIT",(function(){return{}})),Zt=rt("DELAYED_HEARTBEAT",(function(e){return e})),en=function(e){function n(t,n){var r=e.call(this,n)||this;return r.on($t.type,at((function(e,n,s){var a=s.heartbeat,u=s.presenceState;return i(r,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,a({channels:e.channels,channelGroups:e.groups,state:u})];case 1:return r.sent(),t.transition(Vt()),[3,3];case 2:return(n=r.sent())instanceof B?[2,t.transition(Jt(n))]:[3,3];case 3:return[2]}}))}))}))),r.on(Qt.type,at((function(e,t,n){var s=n.leave,a=n.config;return i(r,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:if(a.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,s({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),r.on(Yt.type,at((function(e,n,s){var a=s.heartbeatDelay;return i(r,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,a()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition(Xt())]}}))}))}))),r.on(Zt.type,at((function(e,n,s){var a=s.heartbeat,u=s.retryDelay,c=s.presenceState,l=s.config;return i(r,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,a({channels:e.channels,channelGroups:e.groups,state:c})];case 3:return i.sent(),console.log("after hb call"),[2,t.transition(Vt())];case 4:return(r=i.sent())instanceof Error&&"Aborted"===r.message?[2]:r instanceof B?[2,t.transition(Jt(r))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Wt())];case 7:return[2]}}))}))}))),r}return t(n,e),n}(et),tn=new Ye("HEARTBEAT_STOPPED");tn.on(Ht.type,(function(e,t){return tn.with({channels:u(u([],a(e.channels),!1),a(t.payload.channels),!1),groups:u(u([],a(e.groups),!1),a(t.payload.groups),!1)})})),tn.on(qt.type,(function(e,t){return tn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Qt(t.payload.channels,t.payload.groups)])})),tn.on(Lt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),tn.on(Bt.type,(function(e,t){return tn.with({channels:e.channels,groups:e.groups},[Qt(e.channels,e.groups)])})),tn.on(zt.type,(function(e,t){return an.with(void 0,[Qt(e.channels,e.groups)])}));var nn=new Ye("HEARTBEATCOOLDOWN");nn.onEnter((function(){return Yt()})),nn.onExit((function(){return Yt.cancel})),nn.on(Xt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],a(e.channels),!1),a(t.payload.channels),!1),groups:u(u([],a(e.groups),!1),a(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Qt(t.payload.channels,t.payload.groups)])})),nn.on(Bt.type,(function(e){return tn.with({channels:e.channels,groups:e.groups},[Qt(e.channels,e.groups)])})),nn.on(zt.type,(function(e,t){return an.with(void 0,[Qt(e.channels,e.groups)])}));var rn=new Ye("HEARTBEAT_FAILED");rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],a(e.channels),!1),a(t.payload.channels),!1),groups:u(u([],a(e.groups),!1),a(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Qt(t.payload.channels,t.payload.groups)])})),rn.on(Lt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Bt.type,(function(e,t){return tn.with({channels:e.channels,groups:e.groups},[Qt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return an.with(void 0,[Qt(e.channels,e.groups)])}));var on=new Ye("HEARBEAT_RECONNECTING");on.onEnter((function(e){return Zt(e)})),on.onExit((function(){return Zt.cancel})),on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],a(e.channels),!1),a(t.payload.channels),!1),groups:u(u([],a(e.groups),!1),a(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Qt(t.payload.channels,t.payload.groups)])})),on.on(Bt.type,(function(e,t){tn.with({channels:e.channels,groups:e.groups},[Qt(e.channels,e.groups)])})),on.on(Vt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups})})),on.on(Jt.type,(function(e,t){return on.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),on.on(Wt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),on.on(zt.type,(function(e,t){return an.with(void 0,[Qt(e.channels,e.groups)])}));var sn=new Ye("HEARTBEATING");sn.onEnter((function(e){return $t(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],a(e.channels),!1),a(t.payload.channels),!1),groups:u(u([],a(e.groups),!1),a(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Qt(t.payload.channels,t.payload.groups)])})),sn.on(Jt.type,(function(e,t){return on.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return tn.with({channels:e.channels,groups:e.groups},[Qt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return an.with(void 0,[Qt(e.channels,e.groups)])}));var an=new Ye("HEARTBEAT_INACTIVE");an.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})})),an.on(qt.type,(function(e,t){return an.with()}));var un=function(){function e(e){var t=this;this.engine=new Ze,this.channels=[],this.groups=[],this.dispatcher=new en(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(an,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],a(this.channels),!1),a(null!=t?t:[]),!1),this.groups=u(u([],a(this.groups),!1),a(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),cn=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){return 1e3*this.delay}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){var t=1e3*Math.trunc(Math.pow(2,e))+1e3*Math.random();return t>15e4?15e4:t}}},e}(),ln=function(){function e(e){var t=this,r=e.networking,i=e.cbor,o=new y({setup:e});this._config=o;var c=new E({config:o}),l=e.cryptography;r.init(o);var p=new L(o,i);this._tokenManager=p;var h=new U({maximumSamplesCount:6e4});this._telemetryManager=h;var f={config:o,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile};this.File=e.PubNubFile,this.encryptFile=function(e,n){return l.encryptFile(e,n,t.File)},this.decryptFile=function(e,n){return l.decryptFile(e,n,t.File)};var d=W.bind(this,f,Je),g=W.bind(this,f,ie),v=W.bind(this,f,se),m=W.bind(this,f,ue),b=W.bind(this,f,We),_=new F;if(this._listenerManager=_,this.iAmHere=W.bind(this,f,se),this.iAmAway=W.bind(this,f,ie),this.setPresenceState=W.bind(this,f,ue),this.handshake=W.bind(this,f,Xe),this.receiveMessages=W.bind(this,f,$e),!0===o.enableEventEngine){if(o.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),o.getHeartbeatInterval()){var O=new un({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*f.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:f.config,presenceState:this.presenceState});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Ft({handshake:this.handshake,receiveEvents:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:f.config,emitEvents:function(e){var t,n;try{for(var r=s(e),i=r.next();!i.done;i=r.next()){var o=i.value;_.announceMessage(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},emitStatus:function(e){_.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.eventEngine=P}else{var S=new M({timeEndpoint:d,leaveEndpoint:g,heartbeatEndpoint:v,setStateEndpoint:m,subscribeEndpoint:b,crypto:f.crypto,config:f.config,listenerManager:_,getFileUrl:function(e){return ve(f,e)}});this.subscribe=S.adaptSubscribeChange.bind(S),this.unsubscribe=S.adaptUnsubscribeChange.bind(S),this.disconnect=S.disconnect.bind(S),this.reconnect=S.reconnect.bind(S),this.unsubscribeAll=S.unsubscribeAll.bind(S),this.getSubscribedChannels=S.getSubscribedChannels.bind(S),this.getSubscribedChannelGroups=S.getSubscribedChannelGroups.bind(S),this.setState=S.adaptStateChange.bind(S),this.presence=S.adaptPresenceChange.bind(S),this.destroy=function(e){S.unsubscribeAll(e),S.disconnect()}}this.addListener=_.addListener.bind(_),this.removeListener=_.removeListener.bind(_),this.removeAllListeners=_.removeAllListeners.bind(_),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:W.bind(this,f,Y),listChannels:W.bind(this,f,Z),addChannels:W.bind(this,f,X),removeChannels:W.bind(this,f,$),deleteGroup:W.bind(this,f,Q)},this.push={addChannels:W.bind(this,f,ee),removeChannels:W.bind(this,f,te),deleteDevice:W.bind(this,f,re),listChannels:W.bind(this,f,ne)},this.hereNow=W.bind(this,f,ce),this.whereNow=W.bind(this,f,oe),this.getState=W.bind(this,f,ae),this.grant=W.bind(this,f,je),this.grantToken=W.bind(this,f,Ie),this.audit=W.bind(this,f,Me),this.revokeToken=W.bind(this,f,Ge),this.publish=W.bind(this,f,Fe),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=W.bind(this,f,Le),this.history=W.bind(this,f,He),this.deleteMessages=W.bind(this,f,qe),this.messageCounts=W.bind(this,f,ze),this.fetchMessages=W.bind(this,f,Ve),this.addMessageAction=W.bind(this,f,le),this.removeMessageAction=W.bind(this,f,pe),this.getMessageActions=W.bind(this,f,he),this.listFiles=W.bind(this,f,fe);var w=W.bind(this,f,de);this.publishFile=W.bind(this,f,ye),this.sendFile=ge({generateUploadUrl:w,publishFile:this.publishFile,modules:f}),this.getFileUrl=function(e){return ve(f,e)},this.downloadFile=W.bind(this,f,me),this.deleteFile=W.bind(this,f,be),this.objects={getAllUUIDMetadata:W.bind(this,f,_e),getUUIDMetadata:W.bind(this,f,Oe),setUUIDMetadata:W.bind(this,f,Pe),removeUUIDMetadata:W.bind(this,f,Se),getAllChannelMetadata:W.bind(this,f,we),getChannelMetadata:W.bind(this,f,Ee),setChannelMetadata:W.bind(this,f,Te),removeChannelMetadata:W.bind(this,f,ke),getChannelMembers:W.bind(this,f,Ce),setChannelMembers:function(e){for(var r=[],i=1;i=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function hn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var i=function(e){return"string"==typeof e||e instanceof String}(r),o=r,s=e[r];Array.isArray(r)||i&&r.indexOf(",")>=0?o=(i?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||i&&!isNaN(r))&&(o=String.fromCharCode(i?parseInt(r,10):10));n[o]=t(s)?hn(s):s})),n}var fn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),dn={exports:{}},yn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;is.depthLimit)return void Sn(vn,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void Sn(vn,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;at?1:0}function Tn(e,t,n,r){void 0===r&&(r=On());var i,o=kn(e,"",0,[],void 0,0,r)||e;try{i=0===_n.length?JSON.stringify(o,t,n):JSON.stringify(o,Cn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==bn.length;){var s=bn.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function kn(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;as.depthLimit)return void Sn(vn,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void Sn(vn,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a0)for(var r=0;r<_n.length;r++){var i=_n[r];if(i[1]===t&&i[0]===n){n=i[2],_n.splice(r,1);break}}return e.call(this,t,n)}}var Nn=String.prototype.replace,An=/%20/g,Rn="RFC3986",Mn={default:Rn,formatters:{RFC1738:function(e){return Nn.call(e,An,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:Rn},jn=Mn,Un=Object.prototype.hasOwnProperty,xn=Array.isArray,Dn=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),In=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xn(n)){for(var r=[],i=0;i=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===jn.RFC1738&&(40===u||41===u)?s+=o.charAt(a):u<128?s+=Dn[u]:u<2048?s+=Dn[192|u>>6]+Dn[128|63&u]:u<55296||u>=57344?s+=Dn[224|u>>12]+Dn[128|u>>6&63]+Dn[128|63&u]:(a+=1,u=65536+((1023&u)<<10|1023&o.charCodeAt(a)),s+=Dn[240|u>>18]+Dn[128|u>>12&63]+Dn[128|u>>6&63]+Dn[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xn(e)){for(var n=[],r=0;r0?g.join(",")||null:void 0}];else if(Hn(a))O=a;else{var S=Object.keys(g);O=u?S.sort(u):S}for(var w=0;w-1?e.split(","):e},rr=function(e,t,n,r){if(e){var i=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(i),a=s?i.slice(0,s.index):i,u=[];if(a){if(!n.plainObjects&&Yn.call(Object.prototype,a)&&!n.allowPrototypes)return;u.push(a)}for(var c=0;n.depth>0&&null!==(s=o.exec(i))&&c=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&a!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(s=[])[c]=i:"__proto__"!==u&&(s[u]=i):s={0:i}}i=s}return i}(u,t,n,r)}},ir=function(e,t){var n,r=e,i=function(e){if(!e)return Xn;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Xn.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Fn.default;if(void 0!==e.format){if(!Ln.call(Fn.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Fn.formatters[n],i=Xn.filter;return("function"==typeof e.filter||Hn(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Xn.addQueryPrefix,allowDots:void 0===e.allowDots?Xn.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Xn.charsetSentinel,delimiter:void 0===e.delimiter?Xn.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Xn.encode,encoder:"function"==typeof e.encoder?e.encoder:Xn.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Xn.encodeValuesOnly,filter:i,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Xn.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Xn.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Xn.strictNullHandling}}(t);"function"==typeof i.filter?r=(0,i.filter)("",r):Hn(i.filter)&&(n=i.filter);var o,s=[];if("object"!=typeof r||null===r)return"";o=t&&t.arrayFormat in Bn?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=Bn[o];n||(n=Object.keys(r)),i.sort&&n.sort(i.sort);for(var u=0;u0?p+l:""},or={formats:Mn,parse:function(e,t){var n=function(e){if(!e)return er;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?er.charset:e.charset;return{allowDots:void 0===e.allowDots?er.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:er.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:er.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:er.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:er.comma,decoder:"function"==typeof e.decoder?e.decoder:er.decoder,delimiter:"string"==typeof e.delimiter||Qn.isRegExp(e.delimiter)?e.delimiter:er.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:er.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:er.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:er.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:er.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:er.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=t.parameterLimit===1/0?void 0:t.parameterLimit,s=i.split(t.delimiter,o),a=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zn(l)?[l]:l),Yn.call(r,c)?r[c]=Qn.combine(r[c],l):r[c]=l}return r}(e,n):e,i=n.plainObjects?Object.create(null):{},o=Object.keys(r),s=0;s=this._maxRetries)return!1;if(this._retryCallback)try{var n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fr.has(t.status))return!0;if(e){if(e.code&&hr.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pr.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pr.prototype.then=function(e,t){var n=this;if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise((function(e,t){r.on("abort",(function(){if(!(n._maxRetries&&n._maxRetries>n._retries))if(n.timedout&&n.timedoutError)t(n.timedoutError);else{var e=new Error("Aborted");e.code="ABORTED",e.status=n.status,e.method=n.method,e.url=n.url,t(e)}})),r.end((function(n,r){n?t(n):e(r)}))}))}return this._fullfilledPromise.then(e,t)},pr.prototype.catch=function(e){return this.then(void 0,e)},pr.prototype.use=function(e){return e(this),this},pr.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pr.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pr.prototype.get=function(e){return this._header[e.toLowerCase()]},pr.prototype.getHeader=pr.prototype.get,pr.prototype.set=function(e,t){if(cr(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.set(n,e[n]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pr.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pr.prototype.field=function(e,t){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(cr(e)){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&this.field(n,e[n]);return this}if(Array.isArray(t)){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&this.field(e,t[r]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),this._getFormData().append(e,t),this},pr.prototype.abort=function(){return this._aborted||(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort")),this},pr.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization","Basic ".concat(r("".concat(e,":").concat(t))));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer ".concat(e))}return this},pr.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pr.prototype.redirects=function(e){return this._maxRedirects=e,this},pr.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pr.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pr.prototype.send=function(e){var t=cr(e),n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&cr(this._data))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this._data[r]=e[r]);else"string"==typeof e?(n||this.type("form"),(n=this._header["content-type"])&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?"".concat(this._data,"&").concat(e):e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)||n||this.type("json"),this},pr.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pr.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var n=this.url.slice(t+1).split("&");"function"==typeof this._sort?n.sort(this._sort):n.sort(),this.url=this.url.slice(0,t)+"?"+n.join("&")}}},pr.prototype._appendQueryString=function(){console.warn("Unsupported")},pr.prototype._timeoutError=function(e,t,n){if(!this._aborted){var r=new Error("".concat(e+t,"ms exceeded"));r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)}},pr.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};var dr={};function yr(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return gr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}function gr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0||e instanceof Object)?t(e):null)},m.prototype.toError=function(){var e=this.req,t=e.method,n=e.url,r="cannot ".concat(t," ").concat(n," (").concat(this.status,")"),i=new Error(r);return i.status=this.status,i.method=t,i.url=n,i},h.Response=m,i(b.prototype),a(b.prototype),b.prototype.type=function(e){return this.set("Content-Type",h.types[e]||e),this},b.prototype.accept=function(e){return this.set("Accept",h.types[e]||e),this},b.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"===n(t)&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var i=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,i)},b.prototype.query=function(e){return"string"!=typeof e&&(e=d(e)),e&&this._query.push(e),this},b.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},b.prototype._getFormData=function(){return this._formData||(this._formData=new r.FormData),this._formData},b.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},b.prototype.crossDomainError=function(){var e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},b.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},b.prototype.ca=b.prototype.agent,b.prototype.buffer=b.prototype.ca,b.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},b.prototype.pipe=b.prototype.write,b.prototype._isHost=function(e){return e&&"object"===n(e)&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},b.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||p,this._finalizeQueryString(),this._end()},b.prototype._setUploadTimeout=function(){var e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((function(){e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},b.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var e=this;this.xhr=h.getXHR();var t=this.xhr,n=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4===n){var r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var r=function(t,n){n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){var i=this._header["content-type"],o=this._serializer||h.serialize[i?i.split(";")[0]:""];!o&&v(i)&&(o=h.serialize["application/json"]),o&&(n=o(n))}for(var s in this.header)null!==this.header[s]&&Object.prototype.hasOwnProperty.call(this.header,s)&&t.setRequestHeader(s,this.header[s]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},h.agent=function(){return new l},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach((function(e){l.prototype[e.toLowerCase()]=function(t,n){var r=new h.Request(e,t);return this._setDefaults(r),n&&r.end(n),r}})),l.prototype.del=l.prototype.delete,h.get=function(e,t,n){var r=h("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.head=function(e,t,n){var r=h("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},h.options=function(e,t,n){var r=h("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.del=_,h.delete=_,h.patch=function(e,t,n){var r=h("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.post=function(e,t,n){var r=h("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},h.put=function(e,t,n){var r=h("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(dn,dn.exports);var wr=dn.exports;function Er(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var i=(new Date).getTime()-t,o=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(o," / ").concat(i,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Tr(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Er)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var i=e;if(t.abortSignal)var o=t.abortSignal.subscribe((function(){i.abort(),o()}));return!0===t.forceBuffered?i="undefined"==typeof Blob?i.buffer().responseType("arraybuffer"):i.responseType("arraybuffer"):!1===t.forceBuffered&&(i=i.buffer(!1)),(i=i.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),i.end((function(e,i){var o,s={};if(s.error=null!==e,s.operation=t.operation,i&&i.status&&(s.statusCode=i.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{s.errorData=JSON.parse(e.response.text)}catch(t){s.errorData=e}else s.errorData=e;return s.category=r._detectErrorCategory(e),n(s,null)}if(t.ignoreBody)o={headers:i.headers,redirects:i.redirects,response:i};else try{o=JSON.parse(i.text)}catch(e){return s.errorData=i,s.error=!0,n(s,null)}return o.error&&1===o.error&&o.status&&o.message&&o.service?(s.errorData=o,s.statusCode=o.status,s.error=!0,s.category=r._detectErrorCategory(s),n(s,null)):(o.error&&o.error.message&&(s.errorData=o.error),n(s,o))})),i}function kr(e,t,n){return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=wr.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,i.sent()]}}))}))}function Cr(e,t,n){var r=wr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Tr.call(this,r,t,n)}function Nr(e,t,n){var r=wr.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Tr.call(this,r,t,n)}function Ar(e,t,n,r){var i=wr.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Tr.call(this,i,n,r)}function Rr(e,t,n,r){var i=wr.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Tr.call(this,i,n,r)}function Mr(e,t,n){var r=wr.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Tr.call(this,r,t,n)}function jr(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ur,xr=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.encryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:s})]}}))}))},e.prototype.decryptFile=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,s;return o(this,(function(o){switch(o.label){case 0:return[4,this.getKey(e)];case 1:return r=o.sent(),[4,t.toArrayBuffer()];case 2:return i=o.sent(),[4,this.decryptArrayBuffer(r,i)];case 3:return s=o.sent(),[2,n.create({name:t.name,data:s})]}}))}))},e.prototype.getKey=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return o(this,(function(i){switch(i.label){case 0:return t=Buffer.from(e),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=i.sent(),r=Buffer.from(Buffer.from(n).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",r,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=jr,i=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,i.concat([o.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(e,t){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return n=t.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:n},e,t.slice(16))]}))}))},e.prototype.encryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Buffer.from(t).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,r)];case 1:return i=o.sent(),s=jr(n.buffer,i),[2,Buffer.from(s).toString("utf8")]}}))}))},e.prototype.decryptString=function(e,t){return i(this,void 0,void 0,(function(){var n,r,i,s;return o(this,(function(o){switch(o.label){case 0:return n=Buffer.from(t),r=n.slice(0,16),i=n.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},e,i)];case 1:return s=o.sent(),[2,Buffer.from(s).toString("utf8")]}}))}))},e.IV_LENGTH=16,e}(),Dr=(Ur=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.data]}))}))},e}(),Ur.supportsFile="undefined"!=typeof File,Ur.supportsBlob="undefined"!=typeof Blob,Ur.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ur.supportsBuffer=!1,Ur.supportsStream=!1,Ur.supportsString=!0,Ur.supportsEncryptFile=!0,Ur.supportsFileUri=!1,Ur);function Ir(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Gr=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,i=void 0===r||r;return t.sdkFamily="Web",t.networking=new pn({del:Mr,get:Nr,post:Ar,patch:Rr,sendBeacon:Ir,getfile:Cr,postfile:kr}),t.cbor=new fn((function(e){return hn(p.decode(e))}),g),t.PubNubFile=Dr,t.cryptography=new xr,n=e.call(this,t)||this,i&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n}(ln);return Gr})); diff --git a/lib/core/components/config.js b/lib/core/components/config.js index 0ef3a179c..5935a795c 100644 --- a/lib/core/components/config.js +++ b/lib/core/components/config.js @@ -1,17 +1,6 @@ "use strict"; /* */ /* global location */ -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -23,7 +12,7 @@ var makeDefaultOrigins = function () { return Array.from({ length: 20 }, functio var default_1 = /** @class */ (function () { function default_1(_a) { var setup = _a.setup; - var _b, _c, _d; + var _b, _c, _d, _e; this._PNSDKSuffix = {}; this.instanceId = "pn-".concat(uuid_1.default.createUUID()); this.secretKey = setup.secretKey || setup.secret_key; @@ -51,10 +40,8 @@ var default_1 = /** @class */ (function () { this.customDecrypt = setup.customDecrypt; this.fileUploadPublishRetryLimit = (_b = setup.fileUploadPublishRetryLimit) !== null && _b !== void 0 ? _b : 5; this.useRandomIVs = (_c = setup.useRandomIVs) !== null && _c !== void 0 ? _c : true; - // flag for beta subscribe feature enablement - this.enableSubscribeBeta = (_d = setup.enableSubscribeBeta) !== null && _d !== void 0 ? _d : false; - // reconnection configuration settings to apply reconnection settings in subscription - this.reconnectionConfiguration = setup.reconnectionConfiguration || { reconnectionPolicy: 'None' }; + this.enableEventEngine = (_d = setup.enableEventEngine) !== null && _d !== void 0 ? _d : false; + this.maintainPresenceState = (_e = setup.maintainPresenceState) !== null && _e !== void 0 ? _e : true; // if location config exist and we are in https, force secure to true. if (typeof location !== 'undefined' && location.protocol === 'https:') { this.secure = true; @@ -66,6 +53,9 @@ var default_1 = /** @class */ (function () { this.useInstanceId = setup.useInstanceId || false; this.useRequestId = setup.useRequestId || false; this.requestMessageCountThreshold = setup.requestMessageCountThreshold; + if (setup.retryConfiguration) { + this.setRetryConfiguration(setup.retryConfiguration); + } // set timeout to how long a transaction request will wait for the server (default 15 seconds) this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000); // set timeout to how long a subscribe event loop will run (default 310 seconds) @@ -184,8 +174,20 @@ var default_1 = /** @class */ (function () { default_1.prototype.getVersion = function () { return '7.2.3'; }; - default_1.prototype.setReconnectionConfiguration = function (reconnectionPolicy, maximumReconnectionRetries) { - this.reconnectionConfiguration = __assign(__assign({}, config.reconnectionConfiguration), { reconnectionPolicy: reconnectionPolicy, maximumReconnectionRetries: maximumReconnectionRetries }); + default_1.prototype.setRetryConfiguration = function (configuration) { + if (configuration.minimumdelay < 2) { + throw new Error('Minimum delay can not be set less than 2 seconds for retry'); + } + if (configuration.maximumDelay > 150) { + throw new Error('Maximum delay can not be set more than 150 seconds for retry'); + } + if (configuration.maximumDelay && maximumRetry > 6) { + throw new Error('Maximum retry for exponential retry policy can not be more than 6'); + } + else if (configuration.maximumRetry > 10) { + throw new Error('Maximum retry for linear retry policy can not be more than 10'); + } + this.retryConfiguration = configuration; }; default_1.prototype._addPnsdkSuffix = function (name, suffix) { this._PNSDKSuffix[name] = suffix; diff --git a/lib/core/constants/categories.js b/lib/core/constants/categories.js index 73970bf60..c976cd42a 100644 --- a/lib/core/constants/categories.js +++ b/lib/core/constants/categories.js @@ -21,4 +21,6 @@ exports.default = { PNConnectedCategory: 'PNConnectedCategory', PNRequestMessageCountExceededCategory: 'PNRequestMessageCountExceededCategory', PNDisconnectedCategory: 'PNDisconnectedCategory', + PNConnectionErrorCategory: 'PNConnectionErrorCategory', + PNDisconnectedUnexpectedlyCategory: 'PNDisconnectedUnexpectedlyCategory', }; diff --git a/lib/core/endpoints/presence/heartbeat.js b/lib/core/endpoints/presence/heartbeat.js index 5d64b9d25..137bfad1a 100644 --- a/lib/core/endpoints/presence/heartbeat.js +++ b/lib/core/endpoints/presence/heartbeat.js @@ -34,13 +34,15 @@ function getRequestTimeout(_a) { } exports.getRequestTimeout = getRequestTimeout; function prepareParams(modules, incomingParams) { - var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, _b = incomingParams.state, state = _b === void 0 ? {} : _b; + var _a = incomingParams.channelGroups, channelGroups = _a === void 0 ? [] : _a, state = incomingParams.state; var config = modules.config; var params = {}; if (channelGroups.length > 0) { params['channel-group'] = channelGroups.join(','); } - params.state = JSON.stringify(state); + if (state) { + params.state = JSON.stringify(state); + } params.heartbeat = config.getPresenceTimeout(); return params; } diff --git a/lib/core/endpoints/subscriptionUtils/handshake.js b/lib/core/endpoints/subscriptionUtils/handshake.js index 03e6dbcd0..6eb2f5333 100644 --- a/lib/core/endpoints/subscriptionUtils/handshake.js +++ b/lib/core/endpoints/subscriptionUtils/handshake.js @@ -28,6 +28,13 @@ var endpoint = { outParams['channel-group'] = params.channelGroups.join(','); } outParams.tt = 0; + if (params.state) { + outParams.state = JSON.stringify(params.state); + } + if (params.filterExpression && params.filterExpression.length > 0) { + outParams['filter-expr'] = params.filterExpression; + } + outParams.ee = ''; return outParams; }, handleResponse: function (_, response) { return ({ diff --git a/lib/core/endpoints/subscriptionUtils/receiveMessages.js b/lib/core/endpoints/subscriptionUtils/receiveMessages.js index adc6bcac1..0bf41a38c 100644 --- a/lib/core/endpoints/subscriptionUtils/receiveMessages.js +++ b/lib/core/endpoints/subscriptionUtils/receiveMessages.js @@ -34,8 +34,12 @@ var endpoint = { if (params.channelGroups && params.channelGroups.length > 0) { outParams['channel-group'] = params.channelGroups.join(','); } + if (params.filterExpression && params.filterExpression.length > 0) { + outParams['filter-expr'] = params.filterExpression; + } outParams.tt = params.timetoken; outParams.tr = params.region; + outParams.ee = ''; return outParams; }, handleResponse: function (_, response) { diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index 11df6967a..b37ef62f0 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -140,12 +140,12 @@ var operations_1 = __importDefault(require("./constants/operations")); var categories_1 = __importDefault(require("./constants/categories")); var uuid_1 = __importDefault(require("./components/uuid")); var event_engine_1 = require("../event-engine"); -var reconnectionDelay_1 = require("../event-engine/core/reconnectionDelay"); +var presence_1 = require("../event-engine/presence/presence"); +var retryPolicy_1 = require("../event-engine/core/retryPolicy"); var default_1 = /** @class */ (function () { // function default_1(setup) { var _this = this; - var _a; var networking = setup.networking, cbor = setup.cbor; var config = new config_1.default({ setup: setup }); this._config = config; @@ -183,15 +183,45 @@ var default_1 = /** @class */ (function () { this.setPresenceState = endpoint_1.default.bind(this, modules, presenceSetStateConfig); this.handshake = endpoint_1.default.bind(this, modules, handshake_1.default); this.receiveMessages = endpoint_1.default.bind(this, modules, receiveMessages_1.default); - if (config.enableSubscribeBeta === true) { - var policy_1 = modules.config.reconnectionConfiguration.reconnectionPolicy; - var maxRetries_1 = (_a = modules.config.reconnectionConfiguration.maximumReconnectionRetries) !== null && _a !== void 0 ? _a : 0; + if (config.enableEventEngine === true) { + if (config.maintainPresenceState) { + this.presenceState = {}; + this.setState = function (args) { + var _a, _b; + (_a = args.channels) === null || _a === void 0 ? void 0 : _a.forEach(function (channel) { return (_this.presenceState[channel] = args.state); }); + (_b = args.channelGroups) === null || _b === void 0 ? void 0 : _b.forEach(function (group) { return (_this.presenceState[group] = args.state); }); + return _this.setPresenceState({ + channels: args.channels, + channelGroups: args.channelGroups, + state: _this.presenceState, + }); + }; + } + if (config.getHeartbeatInterval()) { + var presenceEventEngine = new presence_1.PresenceEventEngine({ + heartbeat: this.iAmHere, + leave: this.iAmAway, + heartbeatDelay: function () { + return new Promise(function (resolve) { return setTimeout(resolve, modules.config.getHeartbeatInterval() * 1000); }); + }, + retryDelay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, + config: modules.config, + presenceState: this.presenceState, + }); + this.presenceEventEngine = presenceEventEngine; + this.join = this.presenceEventEngine.join.bind(presenceEventEngine); + this.leave = this.presenceEventEngine.leave.bind(presenceEventEngine); + this.leaveAll = this.presenceEventEngine.leaveAll.bind(presenceEventEngine); + } var eventEngine = new event_engine_1.EventEngine({ handshake: this.handshake, receiveEvents: this.receiveMessages, - getRetryDelay: function (attempts) { return reconnectionDelay_1.ReconnectionDelay.getDelay(policy_1, attempts); }, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, - shouldRetry: function (_, attempts) { return maxRetries_1 > attempts && policy_1 && policy_1 != 'None'; }, + join: this.join, + leave: this.leave, + leaveAll: this.leaveAll, + presenceState: this.presenceState, + config: modules.config, emitEvents: function (events) { var e_1, _a; try { @@ -565,6 +595,8 @@ var default_1 = /** @class */ (function () { }; default_1.OPERATIONS = operations_1.default; default_1.CATEGORIES = categories_1.default; + default_1.LinearRetryPolicy = retryPolicy_1.RetryPolicy.LinearRetryPolicy; + default_1.ExponentialRetryPolicy = retryPolicy_1.RetryPolicy.ExponentialRetryPolicy; return default_1; }()); exports.default = default_1; diff --git a/lib/event-engine/core/reconnectionDelay.js b/lib/event-engine/core/reconnectionDelay.js index 15d0ae9ee..e2078670a 100644 --- a/lib/event-engine/core/reconnectionDelay.js +++ b/lib/event-engine/core/reconnectionDelay.js @@ -8,13 +8,20 @@ var ReconnectionDelay = /** @class */ (function () { var backoffValue = backoff !== null && backoff !== void 0 ? backoff : 5; switch (policy.toUpperCase()) { case 'LINEAR': - return attempts * backoffValue + Math.random() * 1000; + return attempts * backoffValue + 200; case 'EXPONENTIAL': return Math.trunc(Math.pow(2, attempts - 1)) * 1000 + Math.random() * 1000; default: throw new Error('invalid policy'); } }; + ReconnectionDelay.shouldRetry = function (maxRetries, attempts, policy) { + // maxRetries > attempts && policy && policy != 'None'; + if (policy && policy !== 'None') { + return maxRetries > attempts; + } + return false; + }; return ReconnectionDelay; }()); exports.ReconnectionDelay = ReconnectionDelay; diff --git a/lib/event-engine/core/retryPolicy.js b/lib/event-engine/core/retryPolicy.js new file mode 100644 index 000000000..fbce3277f --- /dev/null +++ b/lib/event-engine/core/retryPolicy.js @@ -0,0 +1,48 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RetryPolicy = void 0; +var RetryPolicy = /** @class */ (function () { + function RetryPolicy() { + } + RetryPolicy.LinearRetryPolicy = function (configuration) { + return { + delay: configuration.delay, + maximumRetry: configuration.maximumRetry, + shouldRetry: function (error, attempt) { + var _a; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return false; + } + return this.maximumRetry > attempt; + }, + getDelay: function (_) { + return this.delay * 1000; + }, + }; + }; + RetryPolicy.ExponentialRetryPolicy = function (configuration) { + return { + minimumDelay: configuration.minimumDelay, + maximumDelay: configuration.maximumDelay, + maximumRetry: configuration.maximumRetry, + shouldRetry: function (error, attempt) { + var _a; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return false; + } + return this.maximumRetry > attempt; + }, + getDelay: function (attempt) { + var calculatedDelay = Math.trunc(Math.pow(2, attempt)) * 1000 + Math.random() * 1000; + if (calculatedDelay > 150000) { + return 150000; + } + else { + return calculatedDelay; + } + }, + }; + }; + return RetryPolicy; +}()); +exports.RetryPolicy = RetryPolicy; diff --git a/lib/event-engine/dispatcher.js b/lib/event-engine/dispatcher.js index 7e20ccf2d..767cc447e 100644 --- a/lib/event-engine/dispatcher.js +++ b/lib/event-engine/dispatcher.js @@ -84,7 +84,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { function EventEngineDispatcher(engine, dependencies) { var _this = _super.call(this, dependencies) || this; _this.on(effects.handshake.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { - var handshake = _a.handshake; + var handshake = _a.handshake, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, e_1; return __generator(this, function (_b) { @@ -98,11 +98,12 @@ var EventEngineDispatcher = /** @class */ (function (_super) { abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, + filterExpression: config.filterExpression, + state: presenceState, })]; case 2: result = _b.sent(); - engine.transition(events.handshakingSuccess(result)); - return [3 /*break*/, 4]; + return [2 /*return*/, engine.transition(events.handshakingSuccess(result))]; case 3: e_1 = _b.sent(); if (e_1 instanceof Error && e_1.message === 'Aborted') { @@ -118,7 +119,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); })); _this.on(effects.receiveEvents.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents; + var receiveEvents = _a.receiveEvents, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_1; return __generator(this, function (_b) { @@ -134,6 +135,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { channelGroups: payload.groups, timetoken: payload.cursor.timetoken, region: payload.cursor.region, + filterExpression: config.filterExpression, })]; case 2: result = _b.sent(); @@ -153,7 +155,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); }); })); - _this.on(effects.emitEvents.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { + _this.on(effects.emitEvents.type, (0, core_1.asyncHandler)(function (payload, _, _a) { var emitEvents = _a.emitEvents; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { @@ -164,7 +166,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); }); })); - _this.on(effects.emitStatus.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { + _this.on(effects.emitStatus.type, (0, core_1.asyncHandler)(function (payload, _, _a) { var emitStatus = _a.emitStatus; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { @@ -174,17 +176,15 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); })); _this.on(effects.reconnect.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; + var receiveEvents = _a.receiveEvents, delay = _a.delay, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_2; return __generator(this, function (_b) { switch (_b.label) { case 0: - if (!shouldRetry(payload.reason, payload.attempts)) { - return [2 /*return*/, engine.transition(events.reconnectingGiveup())]; - } + if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; case 1: _b.sent(); abortSignal.throwIfAborted(); @@ -197,6 +197,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { channelGroups: payload.groups, timetoken: payload.cursor.timetoken, region: payload.cursor.region, + filterExpression: config.filterExpression, })]; case 3: result = _b.sent(); @@ -210,23 +211,23 @@ var EventEngineDispatcher = /** @class */ (function (_super) { return [2 /*return*/, engine.transition(events.reconnectingFailure(error_2))]; } return [3 /*break*/, 5]; - case 5: return [2 /*return*/]; + case 5: return [3 /*break*/, 7]; + case 6: return [2 /*return*/, engine.transition(events.reconnectingGiveup())]; + case 7: return [2 /*return*/]; } }); }); })); _this.on(effects.handshakeReconnect.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { - var handshake = _a.handshake, shouldRetry = _a.shouldRetry, getRetryDelay = _a.getRetryDelay, delay = _a.delay; + var handshake = _a.handshake, delay = _a.delay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_3; return __generator(this, function (_b) { switch (_b.label) { case 0: - if (!shouldRetry(payload.reason, payload.attempts)) { - return [2 /*return*/, engine.transition(events.handshakingReconnectingGiveup())]; - } + if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(getRetryDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; case 1: _b.sent(); abortSignal.throwIfAborted(); @@ -237,6 +238,8 @@ var EventEngineDispatcher = /** @class */ (function (_super) { abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, + filterExpression: config.filterExpression, + state: presenceState, })]; case 3: result = _b.sent(); @@ -250,7 +253,9 @@ var EventEngineDispatcher = /** @class */ (function (_super) { return [2 /*return*/, engine.transition(events.handshakingReconnectingFailure(error_3))]; } return [3 /*break*/, 5]; - case 5: return [2 /*return*/]; + case 5: return [3 /*break*/, 7]; + case 6: return [2 /*return*/, engine.transition(events.handshakingReconnectingGiveup())]; + case 7: return [2 /*return*/]; } }); }); diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index caffec96f..07bde0b2b 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.reconnectingRetry = exports.reconnectingGiveup = exports.reconnectingFailure = exports.reconnectingSuccess = exports.receivingFailure = exports.receivingSuccess = exports.handshakingReconnectingRetry = exports.handshakingReconnectingGiveup = exports.handshakingReconnectingFailure = exports.handshakingReconnectingSuccess = exports.handshakingFailure = exports.handshakingSuccess = exports.restore = exports.reconnect = exports.disconnect = exports.subscriptionChange = void 0; +exports.unsubscribeAll = exports.reconnectingRetry = exports.reconnectingGiveup = exports.reconnectingFailure = exports.reconnectingSuccess = exports.receivingFailure = exports.receivingSuccess = exports.handshakingReconnectingGiveup = exports.handshakingReconnectingFailure = exports.handshakingReconnectingSuccess = exports.handshakingFailure = exports.handshakingSuccess = exports.restore = exports.reconnect = exports.disconnect = exports.subscriptionChange = void 0; var core_1 = require("./core"); exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ channels: channels, @@ -9,7 +9,7 @@ exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', fun }); }); exports.disconnect = (0, core_1.createEvent)('DISCONNECT', function () { return ({}); }); exports.reconnect = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); -exports.restore = (0, core_1.createEvent)('RESTORE', function (channels, groups, timetoken, region) { return ({ +exports.restore = (0, core_1.createEvent)('SUBSCRIPTION_RESTORED', function (channels, groups, timetoken, region) { return ({ channels: channels, groups: groups, timetoken: timetoken, @@ -22,7 +22,6 @@ exports.handshakingReconnectingSuccess = (0, core_1.createEvent)('HANDSHAKE_RECO }); }); exports.handshakingReconnectingFailure = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); exports.handshakingReconnectingGiveup = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_GIVEUP', function () { return ({}); }); -exports.handshakingReconnectingRetry = (0, core_1.createEvent)('HANDSHAKING_RECONNECTING_RETRY', function () { return ({}); }); exports.receivingSuccess = (0, core_1.createEvent)('RECEIVE_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, @@ -32,6 +31,7 @@ exports.reconnectingSuccess = (0, core_1.createEvent)('RECEIVE_RECONNECT_SUCCESS cursor: cursor, events: events, }); }); -exports.reconnectingFailure = (0, core_1.createEvent)('RECEIVING_RECONNECTING_FAILURE', function (error) { return error; }); +exports.reconnectingFailure = (0, core_1.createEvent)('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); exports.reconnectingGiveup = (0, core_1.createEvent)('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); -exports.reconnectingRetry = (0, core_1.createEvent)('RECEIVING_RECONNECTING_RETRY', function () { return ({}); }); +exports.reconnectingRetry = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); +exports.unsubscribeAll = (0, core_1.createEvent)('UNSUBSCRIBE_ALL', function () { }); diff --git a/lib/event-engine/index.js b/lib/event-engine/index.js index 73948e0bd..453f1092e 100644 --- a/lib/event-engine/index.js +++ b/lib/event-engine/index.js @@ -59,6 +59,7 @@ var EventEngine = /** @class */ (function () { this.engine = new core_1.Engine(); this.channels = []; this.groups = []; + this.dependencies = dependencies; this.dispatcher = new dispatcher_1.EventEngineDispatcher(this.engine, dependencies); this._unsubscribeEngine = this.engine.subscribe(function (change) { if (change.type === 'invocationDispatched') { @@ -75,27 +76,67 @@ var EventEngine = /** @class */ (function () { configurable: true }); EventEngine.prototype.subscribe = function (_a) { - var channels = _a.channels, groups = _a.groups, timetoken = _a.timetoken; + var _this = this; + var channels = _a.channels, channelGroups = _a.channelGroups, timetoken = _a.timetoken, withPresence = _a.withPresence; this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); - this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); - this.engine.transition(events.subscriptionChange(this.channels, this.groups, timetoken !== null && timetoken !== void 0 ? timetoken : '0')); + this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((channelGroups !== null && channelGroups !== void 0 ? channelGroups : [])), false); + if (withPresence) { + this.channels.map(function (c) { return _this.channels.push("".concat(c, "-pnpres")); }); + this.groups.map(function (g) { return _this.groups.push("".concat(g, "-pnpres")); }); + } + if (timetoken) { + this.engine.transition(events.restore(this.channels, this.groups, timetoken)); + } + else { + this.engine.transition(events.subscriptionChange(this.channels, this.groups)); + } + if (this.dependencies.join) { + this.dependencies.join({ + channels: this.channels.filter(function (c) { return !c.endsWith('-pnpres'); }), + groups: this.groups.filter(function (g) { return !g.endsWith('-pnpres'); }), + }); + } }; EventEngine.prototype.unsubscribe = function (_a) { + var _this = this; var channels = _a.channels, groups = _a.groups; - this.channels = this.channels.filter(function (channel) { var _a; return (_a = !(channels === null || channels === void 0 ? void 0 : channels.includes(channel))) !== null && _a !== void 0 ? _a : true; }); - this.groups = this.groups.filter(function (group) { var _a; return (_a = !(groups === null || groups === void 0 ? void 0 : groups.includes(group))) !== null && _a !== void 0 ? _a : true; }); + var channlesWithPres = channels === null || channels === void 0 ? void 0 : channels.slice(0); + channels === null || channels === void 0 ? void 0 : channels.map(function (c) { return channlesWithPres.push("".concat(c, "-pnpres")); }); + this.channels = this.channels.filter(function (channel) { return !(channlesWithPres === null || channlesWithPres === void 0 ? void 0 : channlesWithPres.includes(channel)); }); + var groupsWithPres = groups === null || groups === void 0 ? void 0 : groups.slice(0); + groups === null || groups === void 0 ? void 0 : groups.map(function (g) { return groupsWithPres.push("".concat(g, "-pnpres")); }); + this.groups = this.groups.filter(function (group) { return !(groupsWithPres === null || groupsWithPres === void 0 ? void 0 : groupsWithPres.includes(group)); }); + if (this.dependencies.presenceState) { + channels === null || channels === void 0 ? void 0 : channels.forEach(function (c) { return delete _this.dependencies.presenceState[c]; }); + groups === null || groups === void 0 ? void 0 : groups.forEach(function (g) { return delete _this.dependencies.presenceState[g]; }); + } this.engine.transition(events.subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + if (this.dependencies.leave) { + this.dependencies.leave({ + channels: channels, + groups: groups, + }); + } }; EventEngine.prototype.unsubscribeAll = function () { this.channels = []; this.groups = []; + if (this.dependencies.presenceState) { + this.dependencies.presenceState = {}; + } this.engine.transition(events.subscriptionChange(this.channels.slice(0), this.groups.slice(0))); + if (this.dependencies.leaveAll) { + this.dependencies.leaveAll(); + } }; EventEngine.prototype.reconnect = function () { this.engine.transition(events.reconnect()); }; EventEngine.prototype.disconnect = function () { this.engine.transition(events.disconnect()); + if (this.dependencies.leaveAll) { + this.dependencies.leaveAll(); + } }; EventEngine.prototype.dispose = function () { this.disconnect(); diff --git a/lib/event-engine/presence/dispatcher.js b/lib/event-engine/presence/dispatcher.js new file mode 100644 index 000000000..e08ef3dbd --- /dev/null +++ b/lib/event-engine/presence/dispatcher.js @@ -0,0 +1,201 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PresenceEventEngineDispatcher = void 0; +var endpoint_1 = require("../../core/components/endpoint"); +var core_1 = require("../core"); +var effects = __importStar(require("./effects")); +var events = __importStar(require("./events")); +var PresenceEventEngineDispatcher = /** @class */ (function (_super) { + __extends(PresenceEventEngineDispatcher, _super); + function PresenceEventEngineDispatcher(engine, dependencies) { + var _this = _super.call(this, dependencies) || this; + _this.on(effects.heartbeat.type, (0, core_1.asyncHandler)(function (payload, _, _a) { + var heartbeat = _a.heartbeat, presenceState = _a.presenceState; + return __awaiter(_this, void 0, void 0, function () { + var result, e_1; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + _b.trys.push([0, 2, , 3]); + return [4 /*yield*/, heartbeat({ + channels: payload.channels, + channelGroups: payload.groups, + state: presenceState, + })]; + case 1: + result = _b.sent(); + engine.transition(events.heartbeatSuccess()); + return [3 /*break*/, 3]; + case 2: + e_1 = _b.sent(); + if (e_1 instanceof endpoint_1.PubNubError) { + return [2 /*return*/, engine.transition(events.heartbeatFailure(e_1))]; + } + return [3 /*break*/, 3]; + case 3: return [2 /*return*/]; + } + }); + }); + })); + _this.on(effects.leave.type, (0, core_1.asyncHandler)(function (payload, _, _a) { + var leave = _a.leave, config = _a.config; + return __awaiter(_this, void 0, void 0, function () { + var result, e_2; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!!config.suppressLeaveEvents) return [3 /*break*/, 4]; + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + return [4 /*yield*/, leave({ + channels: payload.channels, + channelGroups: payload.groups, + })]; + case 2: + result = _b.sent(); + return [3 /*break*/, 4]; + case 3: + e_2 = _b.sent(); + return [3 /*break*/, 4]; + case 4: return [2 /*return*/]; + } + }); + }); + })); + _this.on(effects.wait.type, (0, core_1.asyncHandler)(function (_, abortSignal, _a) { + var heartbeatDelay = _a.heartbeatDelay; + return __awaiter(_this, void 0, void 0, function () { + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + abortSignal.throwIfAborted(); + return [4 /*yield*/, heartbeatDelay()]; + case 1: + _b.sent(); + abortSignal.throwIfAborted(); + return [2 /*return*/, engine.transition(events.timesUp())]; + } + }); + }); + })); + _this.on(effects.delayedHeartbeat.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { + var heartbeat = _a.heartbeat, retryDelay = _a.retryDelay, presenceState = _a.presenceState, config = _a.config; + return __awaiter(_this, void 0, void 0, function () { + var result, e_3; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; + abortSignal.throwIfAborted(); + return [4 /*yield*/, retryDelay(config.retryConfiguration.getDelay(payload.attempts))]; + case 1: + _b.sent(); + abortSignal.throwIfAborted(); + _b.label = 2; + case 2: + _b.trys.push([2, 4, , 5]); + return [4 /*yield*/, heartbeat({ + channels: payload.channels, + channelGroups: payload.groups, + state: presenceState, + })]; + case 3: + result = _b.sent(); + console.log("after hb call"); + return [2 /*return*/, engine.transition(events.heartbeatSuccess())]; + case 4: + e_3 = _b.sent(); + if (e_3 instanceof Error && e_3.message === 'Aborted') { + return [2 /*return*/]; + } + if (e_3 instanceof endpoint_1.PubNubError) { + return [2 /*return*/, engine.transition(events.heartbeatFailure(e_3))]; + } + return [3 /*break*/, 5]; + case 5: return [3 /*break*/, 7]; + case 6: return [2 /*return*/, engine.transition(events.heartbeatGiveup())]; + case 7: return [2 /*return*/]; + } + }); + }); + })); + return _this; + } + return PresenceEventEngineDispatcher; +}(core_1.Dispatcher)); +exports.PresenceEventEngineDispatcher = PresenceEventEngineDispatcher; diff --git a/lib/event-engine/presence/effects.js b/lib/event-engine/presence/effects.js new file mode 100644 index 000000000..a17d3da99 --- /dev/null +++ b/lib/event-engine/presence/effects.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.delayedHeartbeat = exports.wait = exports.leave = exports.heartbeat = void 0; +var core_1 = require("../core"); +exports.heartbeat = (0, core_1.createEffect)('HEARTBEAT', function (channels, groups) { return ({ + channels: channels, + groups: groups, +}); }); +exports.leave = (0, core_1.createEffect)('LEAVE', function (channels, groups) { return ({ + channels: channels, + groups: groups, +}); }); +exports.wait = (0, core_1.createManagedEffect)('WAIT', function () { return ({}); }); +exports.delayedHeartbeat = (0, core_1.createManagedEffect)('DELAYED_HEARTBEAT', function (context) { return context; }); diff --git a/lib/event-engine/presence/events.js b/lib/event-engine/presence/events.js new file mode 100644 index 000000000..1e07cd196 --- /dev/null +++ b/lib/event-engine/presence/events.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.timesUp = exports.heartbeatGiveup = exports.heartbeatFailure = exports.heartbeatSuccess = exports.leftAll = exports.left = exports.joined = exports.disconnect = exports.reconnect = void 0; +var core_1 = require("../core"); +exports.reconnect = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); +exports.disconnect = (0, core_1.createEvent)('DISCONNECT', function () { return ({}); }); +exports.joined = (0, core_1.createEvent)('JOINED', function (channels, groups) { return ({ + channels: channels, + groups: groups, +}); }); +exports.left = (0, core_1.createEvent)('LEFT', function (channels, groups) { return ({ + channels: channels, + groups: groups, +}); }); +exports.leftAll = (0, core_1.createEvent)('LEFT_ALL', function () { return ({}); }); +exports.heartbeatSuccess = (0, core_1.createEvent)('HEARTBEAT_SUCCESS', function () { return ({}); }); +exports.heartbeatFailure = (0, core_1.createEvent)('HEARTBEAT_FAILURE', function (error) { return error; }); +exports.heartbeatGiveup = (0, core_1.createEvent)('HEARTBEAT_GIVEUP', function () { return ({}); }); +exports.timesUp = (0, core_1.createEvent)('TIMES_UP', function () { return ({}); }); diff --git a/lib/event-engine/presence/presence.js b/lib/event-engine/presence/presence.js new file mode 100644 index 000000000..40c6c11f3 --- /dev/null +++ b/lib/event-engine/presence/presence.js @@ -0,0 +1,102 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PresenceEventEngine = void 0; +var core_1 = require("../core"); +var events = __importStar(require("./events")); +var dispatcher_1 = require("./dispatcher"); +var heartbeat_inactive_1 = require("./states/heartbeat_inactive"); +var PresenceEventEngine = /** @class */ (function () { + function PresenceEventEngine(dependencies) { + var _this = this; + this.engine = new core_1.Engine(); + this.channels = []; + this.groups = []; + this.dispatcher = new dispatcher_1.PresenceEventEngineDispatcher(this.engine, dependencies); + this.dependencies = dependencies; + this._unsubscribeEngine = this.engine.subscribe(function (change) { + if (change.type === 'invocationDispatched') { + _this.dispatcher.dispatch(change.invocation); + } + }); + this.engine.start(heartbeat_inactive_1.HeartbeatInactiveState, undefined); + } + Object.defineProperty(PresenceEventEngine.prototype, "_engine", { + get: function () { + return this.engine; + }, + enumerable: false, + configurable: true + }); + PresenceEventEngine.prototype.join = function (_a) { + var channels = _a.channels, groups = _a.groups; + this.channels = __spreadArray(__spreadArray([], __read(this.channels), false), __read((channels !== null && channels !== void 0 ? channels : [])), false); + this.groups = __spreadArray(__spreadArray([], __read(this.groups), false), __read((groups !== null && groups !== void 0 ? groups : [])), false); + this.engine.transition(events.joined(this.channels.slice(0), this.groups.slice(0))); + }; + PresenceEventEngine.prototype.leave = function (_a) { + var _this = this; + var channels = _a.channels, groups = _a.groups; + if (this.dependencies.presenceState) { + channels === null || channels === void 0 ? void 0 : channels.forEach(function (c) { return delete _this.dependencies.presenceState[c]; }); + groups === null || groups === void 0 ? void 0 : groups.forEach(function (g) { return delete _this.dependencies.presenceState[g]; }); + } + this.engine.transition(events.left(channels !== null && channels !== void 0 ? channels : [], groups !== null && groups !== void 0 ? groups : [])); + }; + PresenceEventEngine.prototype.leaveAll = function () { + this.engine.transition(events.leftAll()); + }; + PresenceEventEngine.prototype.dispose = function () { + this._unsubscribeEngine(); + this.dispatcher.dispose(); + }; + return PresenceEventEngine; +}()); +exports.PresenceEventEngine = PresenceEventEngine; diff --git a/lib/event-engine/presence/states/heartbeat_cooldown.js b/lib/event-engine/presence/states/heartbeat_cooldown.js new file mode 100644 index 000000000..6a490375b --- /dev/null +++ b/lib/event-engine/presence/states/heartbeat_cooldown.js @@ -0,0 +1,64 @@ +"use strict"; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HeartbeatCooldownState = void 0; +var state_1 = require("../../core/state"); +var events_1 = require("../events"); +var effects_1 = require("../effects"); +var heartbeating_1 = require("./heartbeating"); +var heartbeat_stopped_1 = require("./heartbeat_stopped"); +var heartbeat_inactive_1 = require("./heartbeat_inactive"); +exports.HeartbeatCooldownState = new state_1.State('HEARTBEATCOOLDOWN'); +exports.HeartbeatCooldownState.onEnter(function () { return (0, effects_1.wait)(); }); +exports.HeartbeatCooldownState.onExit(function () { return effects_1.wait.cancel; }); +exports.HeartbeatCooldownState.on(events_1.timesUp.type, function (context, _) { + return heartbeating_1.HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }); +}); +exports.HeartbeatCooldownState.on(events_1.joined.type, function (context, event) { + return heartbeating_1.HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); +}); +exports.HeartbeatCooldownState.on(events_1.left.type, function (context, event) { + return heartbeating_1.HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); +}); +exports.HeartbeatCooldownState.on(events_1.disconnect.type, function (context) { + return heartbeat_stopped_1.HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [(0, effects_1.leave)(context.channels, context.groups)]); +}); +exports.HeartbeatCooldownState.on(events_1.leftAll.type, function (context, _) { + return heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [(0, effects_1.leave)(context.channels, context.groups)]); +}); diff --git a/lib/event-engine/presence/states/heartbeat_failed.js b/lib/event-engine/presence/states/heartbeat_failed.js new file mode 100644 index 000000000..349c75756 --- /dev/null +++ b/lib/event-engine/presence/states/heartbeat_failed.js @@ -0,0 +1,62 @@ +"use strict"; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HeartbeatFailedState = void 0; +var state_1 = require("../../core/state"); +var events_1 = require("../events"); +var effects_1 = require("../effects"); +var heartbeating_1 = require("./heartbeating"); +var heartbeat_stopped_1 = require("./heartbeat_stopped"); +var heartbeat_inactive_1 = require("./heartbeat_inactive"); +exports.HeartbeatFailedState = new state_1.State('HEARTBEAT_FAILED'); +exports.HeartbeatFailedState.on(events_1.joined.type, function (context, event) { + return heartbeating_1.HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); +}); +exports.HeartbeatFailedState.on(events_1.left.type, function (context, event) { + return heartbeating_1.HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); +}); +exports.HeartbeatFailedState.on(events_1.reconnect.type, function (context, _) { + return heartbeating_1.HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }); +}); +exports.HeartbeatFailedState.on(events_1.disconnect.type, function (context, _) { + return heartbeat_stopped_1.HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [(0, effects_1.leave)(context.channels, context.groups)]); +}); +exports.HeartbeatFailedState.on(events_1.leftAll.type, function (context, _) { + return heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [(0, effects_1.leave)(context.channels, context.groups)]); +}); diff --git a/lib/event-engine/presence/states/heartbeat_inactive.js b/lib/event-engine/presence/states/heartbeat_inactive.js new file mode 100644 index 000000000..63c3de175 --- /dev/null +++ b/lib/event-engine/presence/states/heartbeat_inactive.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HeartbeatInactiveState = void 0; +var state_1 = require("../../core/state"); +var events_1 = require("../events"); +var heartbeating_1 = require("./heartbeating"); +exports.HeartbeatInactiveState = new state_1.State('HEARTBEAT_INACTIVE'); +exports.HeartbeatInactiveState.on(events_1.joined.type, function (_, event) { + return heartbeating_1.HeartbeatingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + }); +}); +exports.HeartbeatInactiveState.on(events_1.left.type, function (_, event) { return exports.HeartbeatInactiveState.with(); }); diff --git a/lib/event-engine/presence/states/heartbeat_reconnecting.js b/lib/event-engine/presence/states/heartbeat_reconnecting.js new file mode 100644 index 000000000..e677bb017 --- /dev/null +++ b/lib/event-engine/presence/states/heartbeat_reconnecting.js @@ -0,0 +1,86 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HearbeatReconnectingState = void 0; +var state_1 = require("../../core/state"); +var events_1 = require("../events"); +var effects_1 = require("../effects"); +var heartbeating_1 = require("./heartbeating"); +var heartbeat_stopped_1 = require("./heartbeat_stopped"); +var heartbeat_cooldown_1 = require("./heartbeat_cooldown"); +var heartbeat_inactive_1 = require("./heartbeat_inactive"); +var heartbeat_failed_1 = require("./heartbeat_failed"); +exports.HearbeatReconnectingState = new state_1.State('HEARBEAT_RECONNECTING'); +exports.HearbeatReconnectingState.onEnter(function (context) { return (0, effects_1.delayedHeartbeat)(context); }); +exports.HearbeatReconnectingState.onExit(function () { return effects_1.delayedHeartbeat.cancel; }); +exports.HearbeatReconnectingState.on(events_1.joined.type, function (context, event) { + return heartbeating_1.HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); +}); +exports.HearbeatReconnectingState.on(events_1.left.type, function (context, event) { + return heartbeating_1.HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); +}); +exports.HearbeatReconnectingState.on(events_1.disconnect.type, function (context, _) { + heartbeat_stopped_1.HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [(0, effects_1.leave)(context.channels, context.groups)]); +}); +exports.HearbeatReconnectingState.on(events_1.heartbeatSuccess.type, function (context, _) { + return heartbeat_cooldown_1.HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups, + }); +}); +exports.HearbeatReconnectingState.on(events_1.heartbeatFailure.type, function (context, event) { + return exports.HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); +}); +exports.HearbeatReconnectingState.on(events_1.heartbeatGiveup.type, function (context, event) { + return heartbeat_failed_1.HeartbeatFailedState.with({ + channels: context.channels, + groups: context.groups, + }); +}); +exports.HearbeatReconnectingState.on(events_1.leftAll.type, function (context, _) { + return heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [(0, effects_1.leave)(context.channels, context.groups)]); +}); diff --git a/lib/event-engine/presence/states/heartbeat_stopped.js b/lib/event-engine/presence/states/heartbeat_stopped.js new file mode 100644 index 000000000..85aa8d718 --- /dev/null +++ b/lib/event-engine/presence/states/heartbeat_stopped.js @@ -0,0 +1,61 @@ +"use strict"; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HeartbeatStoppedState = void 0; +var state_1 = require("../../core/state"); +var effects_1 = require("../effects"); +var events_1 = require("../events"); +var heartbeat_inactive_1 = require("./heartbeat_inactive"); +var heartbeating_1 = require("./heartbeating"); +exports.HeartbeatStoppedState = new state_1.State('HEARTBEAT_STOPPED'); +exports.HeartbeatStoppedState.on(events_1.joined.type, function (context, event) { + return exports.HeartbeatStoppedState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); +}); +exports.HeartbeatStoppedState.on(events_1.left.type, function (context, event) { + return exports.HeartbeatStoppedState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); +}); +exports.HeartbeatStoppedState.on(events_1.reconnect.type, function (context, _) { + return heartbeating_1.HeartbeatingState.with({ + channels: context.channels, + groups: context.groups, + }); +}); +exports.HeartbeatStoppedState.on(events_1.disconnect.type, function (context, _) { + return exports.HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [(0, effects_1.leave)(context.channels, context.groups)]); +}); +exports.HeartbeatStoppedState.on(events_1.leftAll.type, function (context, _) { + return heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [(0, effects_1.leave)(context.channels, context.groups)]); +}); diff --git a/lib/event-engine/presence/states/heartbeating.js b/lib/event-engine/presence/states/heartbeating.js new file mode 100644 index 000000000..15af51c80 --- /dev/null +++ b/lib/event-engine/presence/states/heartbeating.js @@ -0,0 +1,78 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HeartbeatingState = void 0; +var state_1 = require("../../core/state"); +var events_1 = require("../events"); +var effects_1 = require("../effects"); +var heartbeat_cooldown_1 = require("./heartbeat_cooldown"); +var heartbeat_reconnecting_1 = require("./heartbeat_reconnecting"); +var heartbeat_stopped_1 = require("./heartbeat_stopped"); +var heartbeat_inactive_1 = require("./heartbeat_inactive"); +exports.HeartbeatingState = new state_1.State('HEARTBEATING'); +exports.HeartbeatingState.onEnter(function (context) { return (0, effects_1.heartbeat)(context.channels, context.groups); }); +exports.HeartbeatingState.on(events_1.heartbeatSuccess.type, function (context, _) { + return heartbeat_cooldown_1.HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups, + }); +}); +exports.HeartbeatingState.on(events_1.joined.type, function (context, event) { + return exports.HeartbeatingState.with({ + channels: __spreadArray(__spreadArray([], __read(context.channels), false), __read(event.payload.channels), false), + groups: __spreadArray(__spreadArray([], __read(context.groups), false), __read(event.payload.groups), false), + }); +}); +exports.HeartbeatingState.on(events_1.left.type, function (context, event) { + return exports.HeartbeatingState.with({ + channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), + groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), + }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); +}); +exports.HeartbeatingState.on(events_1.heartbeatFailure.type, function (context, event) { + return heartbeat_reconnecting_1.HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); +}); +exports.HeartbeatingState.on(events_1.disconnect.type, function (context) { + return heartbeat_stopped_1.HeartbeatStoppedState.with({ + channels: context.channels, + groups: context.groups, + }, [(0, effects_1.leave)(context.channels, context.groups)]); +}); +exports.HeartbeatingState.on(events_1.leftAll.type, function (context, _) { + return heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [(0, effects_1.leave)(context.channels, context.groups)]); +}); diff --git a/lib/event-engine/states/handshake_failure.js b/lib/event-engine/states/handshake_failure.js index 4fd6cf486..4f682098a 100644 --- a/lib/event-engine/states/handshake_failure.js +++ b/lib/event-engine/states/handshake_failure.js @@ -13,16 +13,10 @@ var __assign = (this && this.__assign) || function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.HandshakeFailureState = void 0; var state_1 = require("../core/state"); -var effects_1 = require("../effects"); var events_1 = require("../events"); -var handshake_reconnecting_1 = require("./handshake_reconnecting"); var handshake_stopped_1 = require("./handshake_stopped"); var handshaking_1 = require("./handshaking"); exports.HandshakeFailureState = new state_1.State('HANDSHAKE_FAILURE'); -exports.HandshakeFailureState.onEnter(function (context) { return (0, effects_1.emitStatus)({ category: 'PNNetworkIssuesCategory' }); }); -exports.HandshakeFailureState.on(events_1.handshakingReconnectingRetry.type, function (context) { - return handshake_reconnecting_1.HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); -}); exports.HandshakeFailureState.on(events_1.disconnect.type, function (context) { return handshake_stopped_1.HandshakeStoppedState.with({ channels: context.channels, diff --git a/lib/event-engine/states/handshake_reconnecting.js b/lib/event-engine/states/handshake_reconnecting.js index 319e638d9..a050f3838 100644 --- a/lib/event-engine/states/handshake_reconnecting.js +++ b/lib/event-engine/states/handshake_reconnecting.js @@ -10,6 +10,9 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.HandshakeReconnectingState = void 0; var state_1 = require("../core/state"); @@ -19,15 +22,18 @@ var handshake_failure_1 = require("./handshake_failure"); var handshake_stopped_1 = require("./handshake_stopped"); var handshaking_1 = require("./handshaking"); var receiving_1 = require("./receiving"); +var unsubscribed_1 = require("./unsubscribed"); +var categories_1 = __importDefault(require("../../core/constants/categories")); exports.HandshakeReconnectingState = new state_1.State('HANDSHAKE_RECONNECTING'); exports.HandshakeReconnectingState.onEnter(function (context) { return (0, effects_1.handshakeReconnect)(context); }); exports.HandshakeReconnectingState.onExit(function () { return effects_1.handshakeReconnect.cancel; }); exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingSuccess.type, function (context, event) { + var cursor = context.timetoken ? { timetoken: context.timetoken, region: 1 } : event.payload.cursor; return receiving_1.ReceivingState.with({ channels: context.channels, groups: context.groups, - cursor: event.payload.cursor, - }); + cursor: cursor, + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectedCategory })]); }); exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingFailure.type, function (context, event) { return exports.HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); @@ -37,14 +43,20 @@ exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingGiveup.typ groups: context.groups, channels: context.channels, reason: context.reason, - }); + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectionErrorCategory })]); }); exports.HandshakeReconnectingState.on(events_1.disconnect.type, function (context) { return handshake_stopped_1.HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - }); + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); }); exports.HandshakeReconnectingState.on(events_1.subscriptionChange.type, function (_, event) { return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); +exports.HandshakeReconnectingState.on(events_1.restore.type, function (_, event) { + return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); +}); +exports.HandshakeReconnectingState.on(events_1.unsubscribeAll.type, function (_) { + return unsubscribed_1.UnsubscribedState.with(undefined, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); +}); diff --git a/lib/event-engine/states/handshake_stopped.js b/lib/event-engine/states/handshake_stopped.js index 606ba112d..b799697d7 100644 --- a/lib/event-engine/states/handshake_stopped.js +++ b/lib/event-engine/states/handshake_stopped.js @@ -15,7 +15,7 @@ exports.HandshakeStoppedState = void 0; var state_1 = require("../core/state"); var events_1 = require("../events"); var handshaking_1 = require("./handshaking"); -exports.HandshakeStoppedState = new state_1.State('STOPPED'); +exports.HandshakeStoppedState = new state_1.State('HANDSHAKE_STOPPED'); exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (_, event) { return handshaking_1.HandshakingState.with({ channels: event.payload.channels, diff --git a/lib/event-engine/states/handshaking.js b/lib/event-engine/states/handshaking.js index a3830efea..deccc6179 100644 --- a/lib/event-engine/states/handshaking.js +++ b/lib/event-engine/states/handshaking.js @@ -10,6 +10,9 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.HandshakingState = void 0; var state_1 = require("../core/state"); @@ -19,6 +22,7 @@ var handshake_reconnecting_1 = require("./handshake_reconnecting"); var handshake_stopped_1 = require("./handshake_stopped"); var receiving_1 = require("./receiving"); var unsubscribed_1 = require("./unsubscribed"); +var categories_1 = __importDefault(require("../../core/constants/categories")); exports.HandshakingState = new state_1.State('HANDSHAKING'); exports.HandshakingState.onEnter(function (context) { return (0, effects_1.handshake)(context.channels, context.groups); }); exports.HandshakingState.onExit(function () { return effects_1.handshake.cancel; }); @@ -36,7 +40,7 @@ exports.HandshakingState.on(events_1.handshakingSuccess.type, function (context, timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, region: event.payload.region, }, - }); + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectedCategory })]); }); exports.HandshakingState.on(events_1.handshakingFailure.type, function (context, event) { return handshake_reconnecting_1.HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); @@ -47,3 +51,11 @@ exports.HandshakingState.on(events_1.disconnect.type, function (context) { groups: context.groups, }); }); +exports.HandshakingState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(); }); +exports.HandshakingState.on(events_1.restore.type, function (_, event) { + return exports.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); +}); diff --git a/lib/event-engine/states/receive_failure.js b/lib/event-engine/states/receive_failure.js index 0337c4439..4eb9e2b72 100644 --- a/lib/event-engine/states/receive_failure.js +++ b/lib/event-engine/states/receive_failure.js @@ -1,24 +1,18 @@ "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReceiveFailureState = void 0; var state_1 = require("../core/state"); var events_1 = require("../events"); -var receive_reconnecting_1 = require("./receive_reconnecting"); +var handshaking_1 = require("./handshaking"); var receive_stopped_1 = require("./receive_stopped"); -exports.ReceiveFailureState = new state_1.State('RECEIVE_FAILURE'); +var unsubscribed_1 = require("./unsubscribed"); +exports.ReceiveFailureState = new state_1.State('RECEIVE_FAILED'); exports.ReceiveFailureState.on(events_1.reconnectingRetry.type, function (context) { - return receive_reconnecting_1.ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0 })); + return handshaking_1.HandshakingState.with({ + channels: context.channels, + groups: context.groups, + timetoken: context.cursor.timetoken, + }); }); exports.ReceiveFailureState.on(events_1.disconnect.type, function (context) { return receive_stopped_1.ReceiveStoppedState.with({ @@ -27,3 +21,18 @@ exports.ReceiveFailureState.on(events_1.disconnect.type, function (context) { cursor: context.cursor, }); }); +exports.ReceiveFailureState.on(events_1.subscriptionChange.type, function (_, event) { + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); +}); +exports.ReceiveFailureState.on(events_1.restore.type, function (_, event) { + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); +}); +exports.ReceiveFailureState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(undefined); }); diff --git a/lib/event-engine/states/receive_reconnecting.js b/lib/event-engine/states/receive_reconnecting.js index 255889833..b7e0dc562 100644 --- a/lib/event-engine/states/receive_reconnecting.js +++ b/lib/event-engine/states/receive_reconnecting.js @@ -10,6 +10,9 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReceiveReconnectingState = void 0; var state_1 = require("../core/state"); @@ -18,6 +21,8 @@ var events_1 = require("../events"); var receiving_1 = require("./receiving"); var receive_failure_1 = require("./receive_failure"); var receive_stopped_1 = require("./receive_stopped"); +var unsubscribed_1 = require("./unsubscribed"); +var categories_1 = __importDefault(require("../../core/constants/categories")); exports.ReceiveReconnectingState = new state_1.State('RECEIVE_RECONNECTING'); exports.ReceiveReconnectingState.onEnter(function (context) { return (0, effects_1.reconnect)(context); }); exports.ReceiveReconnectingState.onExit(function () { return effects_1.reconnect.cancel; }); @@ -37,20 +42,24 @@ exports.ReceiveReconnectingState.on(events_1.reconnectingGiveup.type, function ( channels: context.channels, cursor: context.cursor, reason: context.reason, - }, [(0, effects_1.emitStatus)({ category: 'PNDisconnectedCategory' })]); + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedUnexpectedlyCategory })]); }); exports.ReceiveReconnectingState.on(events_1.disconnect.type, function (context) { return receive_stopped_1.ReceiveStoppedState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, - }, [(0, effects_1.emitStatus)({ category: 'PNDisconnectedCategory' })]); + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); }); -exports.ReceiveReconnectingState.on(events_1.restore.type, function (context) { +exports.ReceiveReconnectingState.on(events_1.restore.type, function (context, event) { + var _a, _b; return receiving_1.ReceivingState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: (_a = event.payload.timetoken) !== null && _a !== void 0 ? _a : context.cursor.timetoken, + region: (_b = event.payload.region) !== null && _b !== void 0 ? _b : context.cursor.region, + }, }); }); exports.ReceiveReconnectingState.on(events_1.subscriptionChange.type, function (context, event) { @@ -60,3 +69,6 @@ exports.ReceiveReconnectingState.on(events_1.subscriptionChange.type, function ( cursor: context.cursor, }); }); +exports.ReceiveReconnectingState.on(events_1.unsubscribeAll.type, function (_) { + return unsubscribed_1.UnsubscribedState.with(undefined, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); +}); diff --git a/lib/event-engine/states/receive_stopped.js b/lib/event-engine/states/receive_stopped.js index ac3fd8eff..f8d340e42 100644 --- a/lib/event-engine/states/receive_stopped.js +++ b/lib/event-engine/states/receive_stopped.js @@ -1,20 +1,11 @@ "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReceiveStoppedState = void 0; var state_1 = require("../core/state"); var events_1 = require("../events"); +var handshaking_1 = require("./handshaking"); var receiving_1 = require("./receiving"); +var unsubscribed_1 = require("./unsubscribed"); exports.ReceiveStoppedState = new state_1.State('STOPPED'); exports.ReceiveStoppedState.on(events_1.subscriptionChange.type, function (context, event) { return receiving_1.ReceivingState.with({ @@ -23,4 +14,17 @@ exports.ReceiveStoppedState.on(events_1.subscriptionChange.type, function (conte cursor: context.cursor, }); }); -exports.ReceiveStoppedState.on(events_1.reconnect.type, function (context) { return receiving_1.ReceivingState.with(__assign({}, context)); }); +exports.ReceiveStoppedState.on(events_1.restore.type, function (context, event) { + return receiving_1.ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); +}); +exports.ReceiveStoppedState.on(events_1.reconnect.type, function (context) { + return handshaking_1.HandshakingState.with({ + channels: context.channels, + groups: context.groups, + }); +}); +exports.ReceiveStoppedState.on(events_1.unsubscribeAll.type, function () { return unsubscribed_1.UnsubscribedState.with(undefined); }); diff --git a/lib/event-engine/states/receiving.js b/lib/event-engine/states/receiving.js index 1d54086b6..5124c564b 100644 --- a/lib/event-engine/states/receiving.js +++ b/lib/event-engine/states/receiving.js @@ -10,6 +10,9 @@ var __assign = (this && this.__assign) || function () { }; return __assign.apply(this, arguments); }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReceivingState = void 0; var state_1 = require("../core/state"); @@ -18,18 +21,24 @@ var events_1 = require("../events"); var unsubscribed_1 = require("./unsubscribed"); var receive_reconnecting_1 = require("./receive_reconnecting"); var receive_stopped_1 = require("./receive_stopped"); +var categories_1 = __importDefault(require("../../core/constants/categories")); exports.ReceivingState = new state_1.State('RECEIVING'); -exports.ReceivingState.onEnter(function (_) { return (0, effects_1.emitStatus)({ category: 'PNConnectedCategory' }); }); exports.ReceivingState.onEnter(function (context) { return (0, effects_1.receiveEvents)(context.channels, context.groups, context.cursor); }); exports.ReceivingState.onExit(function () { return effects_1.receiveEvents.cancel; }); exports.ReceivingState.on(events_1.receivingSuccess.type, function (context, event) { - return exports.ReceivingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor }), [(0, effects_1.emitEvents)(event.payload.events)]); + return exports.ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor }, [ + (0, effects_1.emitEvents)(event.payload.events), + ]); }); exports.ReceivingState.on(events_1.subscriptionChange.type, function (context, event) { if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { return unsubscribed_1.UnsubscribedState.with(undefined); } - return exports.ReceivingState.with(__assign(__assign({}, context), { channels: event.payload.channels, groups: event.payload.groups })); + return exports.ReceivingState.with({ + cursor: context.cursor, + channels: event.payload.channels, + groups: event.payload.groups, + }); }); exports.ReceivingState.on(events_1.receivingFailure.type, function (context, event) { return receive_reconnecting_1.ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); @@ -39,5 +48,8 @@ exports.ReceivingState.on(events_1.disconnect.type, function (context) { channels: context.channels, groups: context.groups, cursor: context.cursor, - }, [(0, effects_1.emitStatus)({ category: 'PNDisconnectedCategory' })]); + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); +}); +exports.ReceivingState.on(events_1.unsubscribeAll.type, function (_) { + return unsubscribed_1.UnsubscribedState.with(undefined, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); }); diff --git a/lib/event-engine/states/unsubscribed.js b/lib/event-engine/states/unsubscribed.js index dcca75e04..40398b038 100644 --- a/lib/event-engine/states/unsubscribed.js +++ b/lib/event-engine/states/unsubscribed.js @@ -12,3 +12,10 @@ exports.UnsubscribedState.on(events_1.subscriptionChange.type, function (_, even timetoken: event.payload.timetoken, }); }); +exports.UnsubscribedState.on(events_1.restore.type, function (_, event) { + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + timetoken: event.payload.timetoken, + }); +}); From 528ca45d55c04ce1032fcea790a9a3bc41b5ae37 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 14:36:34 +0530 Subject: [PATCH 28/63] take-1 fix lint --- .../subscriptionUtils/receiveMessages.js | 2 +- src/event-engine/core/retryPolicy.ts | 6 +- src/event-engine/dispatcher.ts | 60 +++++++++---------- src/event-engine/events.ts | 2 +- src/event-engine/index.ts | 4 +- .../presence/states/heartbeat_failed.ts | 2 +- 6 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/core/endpoints/subscriptionUtils/receiveMessages.js b/src/core/endpoints/subscriptionUtils/receiveMessages.js index 5d259d868..b62c3acb3 100644 --- a/src/core/endpoints/subscriptionUtils/receiveMessages.js +++ b/src/core/endpoints/subscriptionUtils/receiveMessages.js @@ -37,7 +37,7 @@ const endpoint = { } outParams.tt = params.timetoken; outParams.tr = params.region; - outParams.ee=''; + outParams.ee = ''; return outParams; }, diff --git a/src/event-engine/core/retryPolicy.ts b/src/event-engine/core/retryPolicy.ts index 0677e1b92..24de99a14 100644 --- a/src/event-engine/core/retryPolicy.ts +++ b/src/event-engine/core/retryPolicy.ts @@ -22,9 +22,9 @@ export class RetryPolicy { maximumRetry: configuration.maximumRetry, shouldRetry(error: any, attempt: number) { - if (error?.status?.statusCode === 403) { - return false; - } + if (error?.status?.statusCode === 403) { + return false; + } return this.maximumRetry > attempt; }, diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index 2b26aae5f..8b6417450 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -130,39 +130,37 @@ export class EventEngineDispatcher extends Dispatcher { - if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) { - abortSignal.throwIfAborted(); - - await delay(config.retryConfiguration.getDelay(payload.attempts)); - - abortSignal.throwIfAborted(); - - try { - const result = await handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - state: presenceState, - }); - - return engine.transition(events.handshakingReconnectingSuccess(result)); - } catch (error) { - if (error instanceof Error && error.message === 'Aborted') { - return; - } - - if (error instanceof PubNubError) { - return engine.transition(events.handshakingReconnectingFailure(error)); - } + asyncHandler(async (payload, abortSignal, { handshake, delay, presenceState, config }) => { + if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) { + abortSignal.throwIfAborted(); + + await delay(config.retryConfiguration.getDelay(payload.attempts)); + + abortSignal.throwIfAborted(); + + try { + const result = await handshake({ + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + filterExpression: config.filterExpression, + state: presenceState, + }); + + return engine.transition(events.handshakingReconnectingSuccess(result)); + } catch (error) { + if (error instanceof Error && error.message === 'Aborted') { + return; + } + + if (error instanceof PubNubError) { + return engine.transition(events.handshakingReconnectingFailure(error)); } - } else { - return engine.transition(events.handshakingReconnectingGiveup()); } - }, - ), + } else { + return engine.transition(events.handshakingReconnectingGiveup()); + } + }), ); } } diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 21e91aff2..5495d06ed 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -45,7 +45,7 @@ export const reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', (cur export const reconnectingFailure = createEvent('RECEIVE_RECONNECT_FAILURE', (error: PubNubError) => error); export const reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', () => ({})); export const reconnectingRetry = createEvent('RECONNECT', () => ({})); -export const unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', () => {}); +export const unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', () => ({})); export type Events = MapOf< | typeof subscriptionChange diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index 02f86914c..c4dad0d09 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -63,11 +63,11 @@ export class EventEngine { } unsubscribe({ channels, groups }: { channels?: string[]; groups?: string[] }) { - let channlesWithPres: any = channels?.slice(0); + const channlesWithPres: any = channels?.slice(0); channels?.map((c) => channlesWithPres.push(`${c}-pnpres`)); this.channels = this.channels.filter((channel) => !channlesWithPres?.includes(channel)); - let groupsWithPres: any = groups?.slice(0); + const groupsWithPres: any = groups?.slice(0); groups?.map((g) => groupsWithPres.push(`${g}-pnpres`)); this.groups = this.groups.filter((group) => !groupsWithPres?.includes(group)); diff --git a/src/event-engine/presence/states/heartbeat_failed.ts b/src/event-engine/presence/states/heartbeat_failed.ts index 628d309ad..14fadf591 100644 --- a/src/event-engine/presence/states/heartbeat_failed.ts +++ b/src/event-engine/presence/states/heartbeat_failed.ts @@ -46,6 +46,6 @@ HeartbeatFailedState.on(disconnect.type, (context, _) => ), ); -HeartbeatFailedState.on(leftAll.type, (context,_) => +HeartbeatFailedState.on(leftAll.type, (context, _) => HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]), ); From 037378da8acf52db9fee71379930edb5a12bbc37 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 16:38:58 +0530 Subject: [PATCH 29/63] fix: elint config --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index 126ec3995..a0d9bda34 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,5 +19,6 @@ module.exports = { 'prefer-destructuring': 0, 'no-unused-vars': 0, '@typescript-eslint/no-unused-vars': 0, + '@typescript-eslint/explicit-module-boundary-types': 'off', }, }; From 944cacacf9d4e39ce7345877d4714cca11abe4c9 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 20:11:16 +0530 Subject: [PATCH 30/63] sync: package-lock --- package-lock.json | 3294 +++++++++++++++------------------------------ 1 file changed, 1066 insertions(+), 2228 deletions(-) diff --git a/package-lock.json b/package-lock.json index f0625d0f3..fc645ef42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,21 @@ { "name": "pubnub", - "version": "7.2.2", + "version": "7.4.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pubnub", - "version": "7.2.2", - "license": "MIT", + "version": "7.4.4", + "license": "SEE LICENSE IN LICENSE", "dependencies": { "agentkeepalive": "^3.5.2", "buffer": "^6.0.3", "cbor-js": "^0.1.0", "cbor-sync": "^1.0.4", "lil-uuid": "^0.1.1", - "superagent": "^6.1.0", - "superagent-proxy": "^3.0.0" + "proxy-agent": "^6.3.0", + "superagent": "^8.1.2" }, "devDependencies": { "@cucumber/cucumber": "^7.3.1", @@ -104,37 +104,22 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/runtime-corejs3": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.0.tgz", - "integrity": "sha512-v1JH7PeAAGBEyTQM9TqojVl+b20zXtesFKCJHu50xMxZKD1fX0TKaKHPsZfFkXfs7D1M9M6Eeqg1FkJ3a0x2dA==", + "node_modules/@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", "dev": true, - "peer": true, - "dependencies": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.10" - }, "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", - "dev": true, - "optional": true, - "engines": { - "node": ">=0.1.90" + "node": ">= 12" } }, "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", "dev": true, "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" + "@cspotcode/source-map-consumer": "0.8.0" }, "engines": { "node": ">=12" @@ -149,39 +134,6 @@ "@cucumber/messages": "^16.0.0" } }, - "node_modules/@cucumber/create-meta/node_modules/@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "dependencies": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "node_modules/@cucumber/create-meta/node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "node_modules/@cucumber/create-meta/node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "node_modules/@cucumber/create-meta/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@cucumber/cucumber": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/@cucumber/cucumber/-/cucumber-7.3.2.tgz", @@ -238,54 +190,6 @@ "regexp-match-indices": "1.0.2" } }, - "node_modules/@cucumber/cucumber/node_modules/@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "dependencies": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "node_modules/@cucumber/cucumber/node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "node_modules/@cucumber/cucumber/node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "node_modules/@cucumber/cucumber/node_modules/cli-table3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", - "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0" - }, - "engines": { - "node": "10.* || >= 12.*" - }, - "optionalDependencies": { - "colors": "1.4.0" - } - }, - "node_modules/@cucumber/cucumber/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@cucumber/gherkin": { "version": "19.0.3", "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-19.0.3.tgz", @@ -312,82 +216,6 @@ "gherkin-javascript": "bin/gherkin" } }, - "node_modules/@cucumber/gherkin-streams/node_modules/@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "dependencies": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "node_modules/@cucumber/gherkin-streams/node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "node_modules/@cucumber/gherkin-streams/node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "node_modules/@cucumber/gherkin-streams/node_modules/source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/@cucumber/gherkin-streams/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/@cucumber/gherkin/node_modules/@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "dependencies": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "node_modules/@cucumber/gherkin/node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "node_modules/@cucumber/gherkin/node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "node_modules/@cucumber/gherkin/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@cucumber/html-formatter": { "version": "15.0.2", "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-15.0.2.tgz", @@ -402,49 +230,6 @@ "cucumber-html-formatter": "bin/cucumber-html-formatter.js" } }, - "node_modules/@cucumber/html-formatter/node_modules/@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "dependencies": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "node_modules/@cucumber/html-formatter/node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "node_modules/@cucumber/html-formatter/node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "node_modules/@cucumber/html-formatter/node_modules/source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/@cucumber/html-formatter/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@cucumber/message-streams": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", @@ -454,7 +239,7 @@ "@cucumber/messages": "^16.0.1" } }, - "node_modules/@cucumber/message-streams/node_modules/@cucumber/messages": { + "node_modules/@cucumber/messages": { "version": "16.0.1", "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", @@ -466,119 +251,30 @@ "uuid": "8.3.2" } }, - "node_modules/@cucumber/message-streams/node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "node_modules/@cucumber/message-streams/node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "node_modules/@cucumber/message-streams/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/@cucumber/messages": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-21.0.1.tgz", - "integrity": "sha512-pGR7iURM4SF9Qp1IIpNiVQ77J9kfxMkPOEbyy+zRmGABnWWCsqMpJdfHeh9Mb3VskemVw85++e15JT0PYdcR3g==", - "dev": true, - "peer": true, - "dependencies": { - "@types/uuid": "8.3.4", - "class-transformer": "0.5.1", - "reflect-metadata": "0.1.13", - "uuid": "9.0.0" - } - }, - "node_modules/@cucumber/pretty-formatter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", - "integrity": "sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==", - "dev": true, - "dependencies": { - "ansi-styles": "^5.0.0", - "cli-table3": "^0.6.0", - "figures": "^3.2.0", - "ts-dedent": "^2.0.0" - }, - "peerDependencies": { - "@cucumber/cucumber": ">=7.0.0", - "@cucumber/messages": "*" - } - }, - "node_modules/@cucumber/pretty-formatter/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/@cucumber/tag-expressions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@cucumber/tag-expressions/-/tag-expressions-3.0.1.tgz", "integrity": "sha512-OGCXaJ1BQXmQ5b9pw+JYsBGumK2/LPZiLmbj1o1JFVeSNs2PY8WPQFSyXrskhrHz5Nd/6lYg7lvGMtFHOncC4w==", "dev": true }, - "node_modules/@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^3.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - } - }, - "node_modules/@eslint-community/regexpp": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", - "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", - "dev": true, - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } - }, "node_modules/@eslint/eslintrc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", - "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.1.0.tgz", + "integrity": "sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.1", - "globals": "^13.19.0", - "ignore": "^5.2.0", + "espree": "^9.3.1", + "globals": "^13.9.0", + "ignore": "^4.0.6", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", + "minimatch": "^3.0.4", "strip-json-comments": "^3.1.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/eslintrc/node_modules/argparse": { @@ -587,6 +283,30 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "13.12.1", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", + "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/eslintrc/node_modules/ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -599,42 +319,20 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/@eslint/js": { - "version": "8.37.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", - "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", + "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.5" + "minimatch": "^3.0.4" }, "engines": { "node": ">=10.10.0" } }, - "node_modules/@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true, - "engines": { - "node": ">=12.22" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -727,31 +425,6 @@ "node": ">=8" } }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -917,13 +590,10 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, - "node_modules/@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "engines": { - "node": ">= 6" - } + "node_modules/@tootallnate/quickjs-emscripten": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", + "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, "node_modules/@tsconfig/node10": { "version": "1.0.8", @@ -949,22 +619,6 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, - "node_modules/@types/chai": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", - "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", - "dev": true - }, - "node_modules/@types/cucumber": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@types/cucumber/-/cucumber-7.0.0.tgz", - "integrity": "sha512-cr5NN8/jmbw3vDKTQfGW0cSzDtkvxixu9bUD6po9U6OEF04XLuukTDldFG34ccDscLkA8bYnZ7VjxP79cIC7tg==", - "deprecated": "This is a stub types definition. @cucumber/cucumber provides its own type definitions, so you do not need this installed.", - "dev": true, - "dependencies": { - "@cucumber/cucumber": "*" - } - }, "node_modules/@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -1039,36 +693,6 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, - "node_modules/@types/node-fetch": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", - "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", - "dev": true, - "dependencies": { - "@types/node": "*", - "form-data": "^3.0.0" - } - }, - "node_modules/@types/node-fetch/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dev": true, - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/@types/pubnub": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", - "integrity": "sha512-Ui58Xsn8/4Ty1hFW0t91ED6FKezzipjO+GEJviOdJdqp817+I5/WMfo5zBsDfjbZQWMqcdrktMauKpUqiIF1wA==", - "dev": true - }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -1085,11 +709,10 @@ "dev": true }, "node_modules/@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", - "dev": true, - "peer": true + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true }, "node_modules/@types/yargs": { "version": "16.0.4", @@ -1332,9 +955,10 @@ } }, "node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "dev": true, "bin": { "acorn": "bin/acorn" }, @@ -1355,6 +979,7 @@ "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, "engines": { "node": ">=0.4.0" } @@ -1365,15 +990,31 @@ "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", "dev": true }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "node_modules/agent-base": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { - "debug": "4" + "ms": "2.1.2" }, "engines": { - "node": ">= 6.0.0" + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/agentkeepalive": { @@ -1497,6 +1138,11 @@ "node": ">=0.10.0" } }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + }, "node_modules/asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -1615,6 +1261,14 @@ "node": "^4.5.0 || >= 5.9" } }, + "node_modules/basic-ftp": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.3.tgz", + "integrity": "sha512-QHX8HLlncOLpy54mh+k/sWIFd0ThmRqwe9ZjELybGZK+tZ8rUb9VO0saKJUROTbE+KhzDUT7xziGpGrW8Kmd+g==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -1624,13 +1278,6 @@ "tweetnacl": "^0.14.3" } }, - "node_modules/becke-ch--regex--s0-0-v1--base--pl--lib": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", - "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==", - "dev": true, - "peer": true - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -1770,6 +1417,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true, "engines": { "node": ">= 0.8" } @@ -1778,7 +1426,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -1922,16 +1569,15 @@ } }, "node_modules/class-transformer": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", - "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", - "dev": true, - "peer": true + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true }, "node_modules/cli-table3": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", - "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", + "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", "dev": true, "dependencies": { "string-width": "^4.2.0" @@ -1940,7 +1586,7 @@ "node": "10.* || >= 12.*" }, "optionalDependencies": { - "@colors/colors": "1.5.0" + "colors": "1.4.0" } }, "node_modules/cliui": { @@ -2091,26 +1737,15 @@ } }, "node_modules/cookiejar": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", - "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" - }, - "node_modules/core-js-pure": { - "version": "3.26.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", - "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", - "dev": true, - "hasInstallScript": true, - "peer": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true }, "node_modules/create-require": { "version": "1.1.1", @@ -2147,188 +1782,6 @@ "node": ">= 8" } }, - "node_modules/cucumber": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.7.tgz", - "integrity": "sha512-pN3AgWxHx8rOi+wOlqjASNETOjf3TgeyqhMNLQam7nSTXgQzju1oAmXkleRQRcXvpVvejcDHiZBLFSfBkqbYpA==", - "deprecated": "Cucumber is publishing new releases under @cucumber/cucumber", - "dev": true, - "peer": true, - "dependencies": { - "assertion-error-formatter": "^3.0.0", - "bluebird": "^3.4.1", - "cli-table3": "^0.5.1", - "colors": "^1.1.2", - "commander": "^3.0.1", - "cucumber-expressions": "^8.1.0", - "cucumber-tag-expressions": "^2.0.2", - "duration": "^0.2.1", - "escape-string-regexp": "^2.0.0", - "figures": "^3.0.0", - "gherkin": "5.0.0", - "glob": "^7.1.3", - "indent-string": "^4.0.0", - "is-generator": "^1.0.2", - "is-stream": "^2.0.0", - "knuth-shuffle-seeded": "^1.0.6", - "lodash": "^4.17.14", - "mz": "^2.4.0", - "progress": "^2.0.0", - "resolve": "^1.3.3", - "serialize-error": "^4.1.0", - "stack-chain": "^2.0.0", - "stacktrace-js": "^2.0.0", - "string-argv": "^0.3.0", - "title-case": "^2.1.1", - "util-arity": "^1.0.2", - "verror": "^1.9.0" - }, - "bin": { - "cucumber-js": "bin/cucumber-js" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cucumber-expressions": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/cucumber-expressions/-/cucumber-expressions-8.3.0.tgz", - "integrity": "sha512-cP2ya0EiorwXBC7Ll7Cj7NELYbasNv9Ty42L4u7sso9KruWemWG1ZiTq4PMqir3SNDSrbykoqI5wZgMbLEDjLQ==", - "deprecated": "This package is now published under @cucumber/cucumber-expressions", - "dev": true, - "peer": true, - "dependencies": { - "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0", - "xregexp": "^4.2.4" - } - }, - "node_modules/cucumber-expressions/node_modules/xregexp": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.4.1.tgz", - "integrity": "sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==", - "dev": true, - "peer": true, - "dependencies": { - "@babel/runtime-corejs3": "^7.12.1" - } - }, - "node_modules/cucumber-pretty": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/cucumber-pretty/-/cucumber-pretty-6.0.1.tgz", - "integrity": "sha512-9uOIZ8x3lgCPROqYc7kqe2e7UrH5TZPZCdj5fVPze1XViG9yv8/8MnFsAnVINDYWVhiql8DJHb3UrZfIPHYH/A==", - "dev": true, - "dependencies": { - "cli-table3": "^0.6.0", - "colors": "^1.4.0", - "figures": "^3.2.0" - }, - "peerDependencies": { - "cucumber": ">=6.0.0 <7.0.0" - } - }, - "node_modules/cucumber-tag-expressions": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/cucumber-tag-expressions/-/cucumber-tag-expressions-2.0.3.tgz", - "integrity": "sha512-+x5j1IfZrBtbvYHuoUX0rl4nUGxaey6Do9sM0CABmZfDCcWXuuRm1fQeCaklIYQgOFHQ6xOHvDSdkMHHpni6tQ==", - "dev": true, - "peer": true - }, - "node_modules/cucumber-tsflow": { - "version": "4.0.0-rc.11", - "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-rc.11.tgz", - "integrity": "sha512-VK/RhJOOxS4KAH6UIkfLsDE2+H7OtP/+cwzx139gldqHP08hoYk/fMwOoXlGWXOOX2O3amJ6RTS0YMF2xCA8Bw==", - "dev": true, - "dependencies": { - "callsites": "^3.1.0", - "log4js": "^6.3.0", - "source-map-support": "^0.5.19", - "underscore": "^1.8.3" - }, - "peerDependencies": { - "@cucumber/cucumber": ">7.0.0-rc || >7.0.0" - } - }, - "node_modules/cucumber/node_modules/ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true, - "peer": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/cucumber/node_modules/cli-table3": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", - "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", - "dev": true, - "peer": true, - "dependencies": { - "object-assign": "^4.1.0", - "string-width": "^2.1.1" - }, - "engines": { - "node": ">=6" - }, - "optionalDependencies": { - "colors": "^1.1.2" - } - }, - "node_modules/cucumber/node_modules/commander": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", - "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", - "dev": true, - "peer": true - }, - "node_modules/cucumber/node_modules/escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true, - "peer": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cucumber/node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", - "dev": true, - "peer": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/cucumber/node_modules/string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "peer": true, - "dependencies": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/cucumber/node_modules/strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", - "dev": true, - "peer": true, - "dependencies": { - "ansi-regex": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -2358,11 +1811,11 @@ } }, "node_modules/data-uri-to-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", - "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-5.0.1.tgz", + "integrity": "sha512-a9l6T1qqDogvvnw0nKlfZzqsyikEBZBClF39V3TFoKhDtGBqHu2HkuomJc02j5zft8zrUaXEuoicLeW54RkzPg==", "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/date-format": { @@ -2431,7 +1884,8 @@ "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true }, "node_modules/deepmerge": { "version": "4.2.2", @@ -2455,17 +1909,16 @@ } }, "node_modules/degenerator": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.2.tgz", - "integrity": "sha512-c0mef3SNQo56t6urUU6tdQAs+ThoD0o9B9MJ8HEt7NQcGEILCRFqQb7ZbP9JAv+QF1Ky5plydhMR/IrqWDm+TQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", + "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", "dependencies": { - "ast-types": "^0.13.2", - "escodegen": "^1.8.1", - "esprima": "^4.0.0", - "vm2": "^3.9.8" + "ast-types": "^0.13.4", + "escodegen": "^2.1.0", + "esprima": "^4.0.1" }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/delayed-stream": { @@ -2480,10 +1933,20 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "dev": true, "engines": { "node": ">= 0.6" } }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -2669,12 +2132,12 @@ "dev": true }, "node_modules/error-stack-parser": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", - "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.7.tgz", + "integrity": "sha512-chLOW0ZGRf4s8raLrDxa5sdkvPec5YdvwbFnqJme4rk0rFajP8mPtrDL1+I+CwrQDCjswDA5sREX7jYQDQs9vA==", "dev": true, "dependencies": { - "stackframe": "^1.3.4" + "stackframe": "^1.1.1" } }, "node_modules/es5-ext": { @@ -2746,47 +2209,33 @@ } }, "node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", "dependencies": { "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" + "estraverse": "^5.2.0", + "esutils": "^2.0.2" }, "bin": { "escodegen": "bin/escodegen.js", "esgenerate": "bin/esgenerate.js" }, "engines": { - "node": ">=4.0" + "node": ">=6.0" }, "optionalDependencies": { "source-map": "~0.6.1" } }, - "node_modules/escodegen/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "engines": { - "node": ">=4.0" - } - }, "node_modules/eslint": { - "version": "8.37.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", - "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", - "dev": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.2", - "@eslint/js": "8.37.0", - "@humanwhocodes/config-array": "^0.11.8", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", + "integrity": "sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q==", + "dev": true, + "dependencies": { + "@eslint/eslintrc": "^1.1.0", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -2794,32 +2243,32 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-visitor-keys": "^3.4.0", - "espree": "^9.5.1", - "esquery": "^1.4.2", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.3.1", + "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^6.0.1", + "globals": "^13.6.0", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", + "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", + "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" }, "bin": { "eslint": "bin/eslint.js" @@ -2909,15 +2358,12 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", - "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/ansi-styles": { @@ -2999,6 +2445,21 @@ "node": ">=10.13.0" } }, + "node_modules/eslint/node_modules/globals": { + "version": "13.12.1", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", + "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/eslint/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -3084,20 +2545,17 @@ } }, "node_modules/espree": { - "version": "9.5.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", - "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", + "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", "dev": true, "dependencies": { - "acorn": "^8.8.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.0" + "acorn": "^8.7.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^3.3.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" } }, "node_modules/esprima": { @@ -3113,9 +2571,9 @@ } }, "node_modules/esquery": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", - "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "dependencies": { "estraverse": "^5.1.0" @@ -3140,7 +2598,6 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, "engines": { "node": ">=4.0" } @@ -3277,7 +2734,8 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true }, "node_modules/fast-safe-stringify": { "version": "2.1.1", @@ -3329,14 +2787,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-uri-to-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", - "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==", - "engines": { - "node": ">= 6" - } - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -3382,22 +2832,6 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -3470,14 +2904,33 @@ } }, "node_modules/formidable": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", - "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==", - "deprecated": "Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", + "integrity": "sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==", + "dependencies": { + "dezalgo": "^1.0.4", + "hexoid": "^1.0.0", + "once": "^1.4.0", + "qs": "^6.11.0" + }, "funding": { "url": "https://ko-fi.com/tunnckoCore/commissions" } }, + "node_modules/formidable/node_modules/qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/fs-extra": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", @@ -3509,44 +2962,10 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", - "dependencies": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/ftp/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "node_modules/ftp/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/ftp/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "node_modules/functional-red-black-tree": { "version": "1.0.1", @@ -3576,7 +2995,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -3587,19 +3005,33 @@ } }, "node_modules/get-uri": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", - "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.1.tgz", + "integrity": "sha512-7ZqONUVqaabogsYNWlYj0t3YZaL6dhuEueZXGF+/YVmf6dHmaFg8/6psJKqhx9QykIDKzpGcy2cn4oV4YC7V/Q==", "dependencies": { - "@tootallnate/once": "1", - "data-uri-to-buffer": "3", - "debug": "4", - "file-uri-to-path": "2", - "fs-extra": "^8.1.0", - "ftp": "^0.3.10" + "basic-ftp": "^5.0.2", + "data-uri-to-buffer": "^5.0.1", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/get-uri/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/get-uri/node_modules/fs-extra": { @@ -3618,7 +3050,7 @@ "node_modules/get-uri/node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -3632,17 +3064,6 @@ "assert-plus": "^1.0.0" } }, - "node_modules/gherkin": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-5.0.0.tgz", - "integrity": "sha512-Y+93z2Nh+TNIKuKEf+6M0FQrX/z0Yv9C2LFfc5NlcGJWRrrTeI/jOg2374y1FOw6ZYQ3RgJBezRkli7CLDubDA==", - "deprecated": "This package is now published under @cucumber/gherkin", - "dev": true, - "peer": true, - "bin": { - "gherkin-javascript": "bin/gherkin" - } - }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -3675,21 +3096,6 @@ "node": ">= 6" } }, - "node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -3715,12 +3121,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, "node_modules/growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -3757,7 +3157,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -3799,7 +3198,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true, "engines": { "node": ">= 0.4" }, @@ -3853,10 +3251,19 @@ "he": "bin/he" } }, + "node_modules/hexoid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", + "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==", + "engines": { + "node": ">=8" + } + }, "node_modules/http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, "dependencies": { "depd": "~1.1.2", "inherits": "2.0.4", @@ -3883,16 +3290,31 @@ } }, "node_modules/http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", + "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" + "agent-base": "^7.1.0", + "debug": "^4.3.4" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/http-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/http-signature": { @@ -3911,15 +3333,15 @@ } }, "node_modules/https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", + "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", "dependencies": { - "agent-base": "6", + "agent-base": "^7.0.2", "debug": "4" }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/humanize-ms": { @@ -3934,6 +3356,7 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -4022,12 +3445,13 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" }, "node_modules/is-arguments": { "version": "1.1.1", @@ -4135,15 +3559,6 @@ "node": ">=0.12.0" } }, - "node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -4542,16 +3957,6 @@ "node": ">=8" } }, - "node_modules/js-sdsl": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", - "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", - "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4785,38 +4190,11 @@ "seed-random": "~2.2.0" } }, - "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/lil-uuid": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", "integrity": "sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY=" }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -4947,11 +4325,11 @@ } }, "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dependencies": { - "yallist": "^3.0.2" + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "engines": { + "node": ">=12" } }, "node_modules/magic-string": { @@ -5188,6 +4566,22 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/mocha/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/mocha/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -5209,6 +4603,21 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/mocha/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/mocha/node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -5227,6 +4636,45 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/mocha/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mocha/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/mocha/node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -5438,9 +4886,9 @@ } }, "node_modules/node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "dev": true, "dependencies": { "whatwg-url": "^5.0.0" @@ -5484,6 +4932,14 @@ "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/object-is": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", @@ -5525,87 +4981,55 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "dependencies": { "wrappy": "1" } }, - "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, + "node_modules/pac-proxy-agent": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.0.tgz", + "integrity": "sha512-t4tRAMx0uphnZrio0S0Jw9zg3oDbz1zVhQ/Vy18FjLfP1XOLNUEjaVxYCYRI6NS+BsMBXKIzV6cTLOkO9AtywA==", "dependencies": { - "yocto-queue": "^0.1.0" + "@tootallnate/quickjs-emscripten": "^0.23.0", + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "get-uri": "^6.0.1", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "pac-resolver": "^7.0.0", + "socks-proxy-agent": "^8.0.1" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">= 14" } }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, + "node_modules/pac-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { - "p-limit": "^3.0.2" + "ms": "2.1.2" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pac-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", - "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", - "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4", - "get-uri": "3", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "5", - "pac-resolver": "^5.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "5" + "node": ">=6.0" }, - "engines": { - "node": ">= 8" + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/pac-resolver": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.0.tgz", - "integrity": "sha512-H+/A6KitiHNNW+bxBKREk2MCGSxljfqRX76NjummWEYIat7ldVXRU3dhRIE3iXZ0nvGBk6smv3nntxKkzRL8NA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", + "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", "dependencies": { - "degenerator": "^3.0.1", - "ip": "^1.1.5", - "netmask": "^2.0.1" + "degenerator": "^5.0.0", + "ip": "^1.1.8", + "netmask": "^2.0.2" }, "engines": { - "node": ">= 8" + "node": ">= 14" } }, "node_modules/pad-right": { @@ -5653,15 +5077,6 @@ "node": ">= 0.8" } }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -5795,14 +5210,6 @@ "node": ">=0.10.0" } }, - "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/prettier": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", @@ -5884,21 +5291,37 @@ ] }, "node_modules/proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", - "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.3.0.tgz", + "integrity": "sha512-0LdR757eTj/JfuU7TL2YCuAZnxWXu3tkJbg4Oq3geW/qFNT/32T0sp2HnZ9O0lMR4q3vwAt0+xCA8SR0WAD0og==", "dependencies": { - "agent-base": "^6.0.0", - "debug": "4", - "http-proxy-agent": "^4.0.0", - "https-proxy-agent": "^5.0.0", - "lru-cache": "^5.1.1", - "pac-proxy-agent": "^5.0.0", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^5.0.0" + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "lru-cache": "^7.14.1", + "pac-proxy-agent": "^7.0.0", + "proxy-from-env": "^1.1.0", + "socks-proxy-agent": "^8.0.1" }, "engines": { - "node": ">= 8" + "node": ">= 14" + } + }, + "node_modules/proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/proxy-from-env": { @@ -5934,6 +5357,7 @@ "version": "6.9.7", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "dev": true, "engines": { "node": ">=0.6" }, @@ -5989,6 +5413,7 @@ "version": "2.4.3", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", + "dev": true, "dependencies": { "bytes": "3.1.2", "http-errors": "1.8.1", @@ -6032,13 +5457,6 @@ "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", "dev": true }, - "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true, - "peer": true - }, "node_modules/regexp-match-indices": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regexp-match-indices/-/regexp-match-indices-1.0.2.tgz", @@ -6321,12 +5739,14 @@ "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true }, "node_modules/seed-random": { "version": "2.2.0", @@ -6335,9 +5755,9 @@ "dev": true }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -6354,37 +5774,9 @@ "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dependencies": { "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, - "node_modules/serialize-error": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", - "integrity": "sha512-5j9GgyGsP9vV9Uj1S0lDCvlsd+gc2LEPVK7HHHte7IyPwOD4lVQFeaX143gx3U5AnoCi+wbcb3mvaxVysjpxEw==", - "dev": true, - "peer": true, - "dependencies": { - "type-fest": "^0.3.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/serialize-error/node_modules/type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", - "dev": true, - "peer": true, + }, "engines": { - "node": ">=6" + "node": ">=10" } }, "node_modules/serialize-javascript": { @@ -6405,7 +5797,8 @@ "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true }, "node_modules/shebang-command": { "version": "2.0.0", @@ -6428,6 +5821,19 @@ "node": ">=8" } }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/sinon": { "version": "7.5.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", @@ -6595,11 +6001,11 @@ } }, "node_modules/socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", + "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "dependencies": { - "ip": "^1.1.5", + "ip": "^2.0.0", "smart-buffer": "^4.2.0" }, "engines": { @@ -6608,18 +6014,39 @@ } }, "node_modules/socks-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", - "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.1.tgz", + "integrity": "sha512-59EjPbbgg8U3x62hhKOFVAmySQUcfRQ4C7Q/D5sEHnZTQRrQlNKINks44DMR1gwXp0p4LaVIeccX2KHTTcHVqQ==", "dependencies": { - "agent-base": "^6.0.2", - "debug": "4", - "socks": "^2.3.3" + "agent-base": "^7.0.1", + "debug": "^4.3.4", + "socks": "^2.7.1" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/socks-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, + "node_modules/socks/node_modules/ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -6630,9 +6057,9 @@ } }, "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", "dev": true, "dependencies": { "buffer-from": "^1.0.0", @@ -6713,9 +6140,9 @@ } }, "node_modules/stackframe": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", - "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.1.tgz", + "integrity": "sha512-h88QkzREN/hy8eRdyNhhsO7RSJ5oyTqxxmmn0dzBIMUclZsjpfmrsg81vp8mjjAs2vAZ72nyWxRUwSwmh0e4xg==", "dev": true }, "node_modules/stacktrace-gps": { @@ -6752,6 +6179,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true, "engines": { "node": ">= 0.6" } @@ -6809,6 +6237,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, "dependencies": { "safe-buffer": "~5.1.0" } @@ -6877,46 +6306,45 @@ } }, "node_modules/superagent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-6.1.0.tgz", - "integrity": "sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==", - "deprecated": "Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at .", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.1.2.tgz", + "integrity": "sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==", "dependencies": { "component-emitter": "^1.3.0", - "cookiejar": "^2.1.2", - "debug": "^4.1.1", - "fast-safe-stringify": "^2.0.7", - "form-data": "^3.0.0", - "formidable": "^1.2.2", + "cookiejar": "^2.1.4", + "debug": "^4.3.4", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.0", + "formidable": "^2.1.2", "methods": "^1.1.2", - "mime": "^2.4.6", - "qs": "^6.9.4", - "readable-stream": "^3.6.0", - "semver": "^7.3.2" + "mime": "2.6.0", + "qs": "^6.11.0", + "semver": "^7.3.8" }, "engines": { - "node": ">= 7.0.0" + "node": ">=6.4.0 <13 || >=14" } }, - "node_modules/superagent-proxy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/superagent-proxy/-/superagent-proxy-3.0.0.tgz", - "integrity": "sha512-wAlRInOeDFyd9pyonrkJspdRAxdLrcsZ6aSnS+8+nu4x1aXbz6FWSTT9M6Ibze+eG60szlL7JA8wEIV7bPWuyQ==", + "node_modules/superagent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { - "debug": "^4.3.2", - "proxy-agent": "^5.0.0" + "ms": "2.1.2" }, "engines": { - "node": ">=6" + "node": ">=6.0" }, - "peerDependencies": { - "superagent": ">= 0.15.4 || 1 || 2 || 3" + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/superagent/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -6926,17 +6354,18 @@ "node": ">= 6" } }, - "node_modules/superagent/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "node_modules/superagent/node_modules/qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "side-channel": "^1.0.4" }, "engines": { - "node": ">= 6" + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/supports-color": { @@ -6996,6 +6425,25 @@ "node": ">= 8" } }, + "node_modules/terser/node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/terser/node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -7029,34 +6477,6 @@ "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "dev": true }, - "node_modules/title-case": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", - "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", - "dev": true, - "peer": true, - "dependencies": { - "no-case": "^2.2.0", - "upper-case": "^1.0.3" - } - }, - "node_modules/title-case/node_modules/lower-case": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", - "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", - "dev": true, - "peer": true - }, - "node_modules/title-case/node_modules/no-case": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", - "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", - "dev": true, - "peer": true, - "dependencies": { - "lower-case": "^1.1.1" - } - }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -7091,6 +6511,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, "engines": { "node": ">=0.6" } @@ -7114,15 +6535,6 @@ "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "dev": true }, - "node_modules/ts-dedent": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", - "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", - "dev": true, - "engines": { - "node": ">=6.10" - } - }, "node_modules/ts-mocha": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-9.0.2.tgz", @@ -7185,12 +6597,12 @@ } }, "node_modules/ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", + "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", + "@cspotcode/source-map-support": "0.7.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -7201,7 +6613,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", + "v8-compile-cache-lib": "^3.0.0", "yn": "3.1.1" }, "bin": { @@ -7303,17 +6715,6 @@ "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", "dev": true }, - "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -7355,9 +6756,9 @@ "dev": true }, "node_modules/typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -7394,17 +6795,11 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true, "engines": { "node": ">= 0.8" } }, - "node_modules/upper-case": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", - "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", - "dev": true, - "peer": true - }, "node_modules/upper-case-first": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", @@ -7432,7 +6827,8 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true }, "node_modules/utils-merge": { "version": "1.0.1", @@ -7444,19 +6840,24 @@ } }, "node_modules/uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", "dev": true, - "peer": true, "bin": { "uuid": "dist/bin/uuid" } }, + "node_modules/v8-compile-cache": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", + "dev": true + }, "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", + "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", "dev": true }, "node_modules/verror": { @@ -7479,21 +6880,6 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "node_modules/vm2": { - "version": "3.9.8", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.8.tgz", - "integrity": "sha512-/1PYg/BwdKzMPo8maOZ0heT7DLI0DAFTm7YQaz/Lim9oIaFZsJs3EdtalvXuBfZwczNwsYhju75NW4d6E+4q+w==", - "dependencies": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - }, - "bin": { - "vm2": "bin/vm2" - }, - "engines": { - "node": ">=6.0" - } - }, "node_modules/void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -7541,6 +6927,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -7601,8 +6988,7 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "node_modules/ws": { "version": "7.4.6", @@ -7634,14 +7020,6 @@ "node": ">=0.4.0" } }, - "node_modules/xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=", - "engines": { - "node": "*" - } - }, "node_modules/y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", @@ -7649,9 +7027,9 @@ "dev": true }, "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/yargs": { "version": "15.4.1", @@ -7784,6 +7162,15 @@ "node": ">=6" } }, + "node_modules/yargs/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/yargs/node_modules/yargs-parser": { "version": "18.1.3", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", @@ -7862,31 +7249,19 @@ "js-tokens": "^4.0.0" } }, - "@babel/runtime-corejs3": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.0.tgz", - "integrity": "sha512-v1JH7PeAAGBEyTQM9TqojVl+b20zXtesFKCJHu50xMxZKD1fX0TKaKHPsZfFkXfs7D1M9M6Eeqg1FkJ3a0x2dA==", - "dev": true, - "peer": true, - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.10" - } - }, - "@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", - "dev": true, - "optional": true + "@cspotcode/source-map-consumer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", + "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "dev": true }, "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", + "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", "dev": true, "requires": { - "@jridgewell/trace-mapping": "0.3.9" + "@cspotcode/source-map-consumer": "0.8.0" } }, "@cucumber/create-meta": { @@ -7896,38 +7271,6 @@ "dev": true, "requires": { "@cucumber/messages": "^16.0.0" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } } }, "@cucumber/cucumber": { @@ -7969,48 +7312,6 @@ "tmp": "^0.2.1", "util-arity": "^1.1.0", "verror": "^1.10.0" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "cli-table3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", - "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", - "dev": true, - "requires": { - "colors": "1.4.0", - "string-width": "^4.2.0" - } - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } } }, "@cucumber/cucumber-expressions": { @@ -8030,38 +7331,6 @@ "requires": { "@cucumber/message-streams": "^2.0.0", "@cucumber/messages": "^16.0.1" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } } }, "@cucumber/gherkin-streams": { @@ -8075,48 +7344,6 @@ "@cucumber/messages": "^16.0.0", "commander": "7.2.0", "source-map-support": "0.5.19" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } } }, "@cucumber/html-formatter": { @@ -8128,48 +7355,6 @@ "@cucumber/messages": "^16.0.1", "commander": "7.2.0", "source-map-support": "0.5.19" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } } }, "@cucumber/message-streams": { @@ -8179,71 +7364,18 @@ "dev": true, "requires": { "@cucumber/messages": "^16.0.1" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } } }, "@cucumber/messages": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-21.0.1.tgz", - "integrity": "sha512-pGR7iURM4SF9Qp1IIpNiVQ77J9kfxMkPOEbyy+zRmGABnWWCsqMpJdfHeh9Mb3VskemVw85++e15JT0PYdcR3g==", + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", "dev": true, - "peer": true, "requires": { - "@types/uuid": "8.3.4", - "class-transformer": "0.5.1", + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", "reflect-metadata": "0.1.13", - "uuid": "9.0.0" - } - }, - "@cucumber/pretty-formatter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", - "integrity": "sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==", - "dev": true, - "requires": { - "ansi-styles": "^5.0.0", - "cli-table3": "^0.6.0", - "figures": "^3.2.0", - "ts-dedent": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true - } + "uuid": "8.3.2" } }, "@cucumber/tag-expressions": { @@ -8252,35 +7384,20 @@ "integrity": "sha512-OGCXaJ1BQXmQ5b9pw+JYsBGumK2/LPZiLmbj1o1JFVeSNs2PY8WPQFSyXrskhrHz5Nd/6lYg7lvGMtFHOncC4w==", "dev": true }, - "@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^3.3.0" - } - }, - "@eslint-community/regexpp": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", - "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", - "dev": true - }, "@eslint/eslintrc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", - "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.1.0.tgz", + "integrity": "sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.1", - "globals": "^13.19.0", - "ignore": "^5.2.0", + "espree": "^9.3.1", + "globals": "^13.9.0", + "ignore": "^4.0.6", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", + "minimatch": "^3.0.4", "strip-json-comments": "^3.1.1" }, "dependencies": { @@ -8290,6 +7407,21 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "globals": { + "version": "13.12.1", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", + "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, "js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -8301,29 +7433,17 @@ } } }, - "@eslint/js": { - "version": "8.37.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", - "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", - "dev": true - }, "@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", + "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.5" + "minimatch": "^3.0.4" } }, - "@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true - }, "@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -8394,28 +7514,6 @@ } } }, - "@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true - }, - "@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, - "@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -8545,10 +7643,10 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, - "@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==" + "@tootallnate/quickjs-emscripten": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", + "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, "@tsconfig/node10": { "version": "1.0.8", @@ -8574,21 +7672,6 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, - "@types/chai": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", - "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", - "dev": true - }, - "@types/cucumber": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@types/cucumber/-/cucumber-7.0.0.tgz", - "integrity": "sha512-cr5NN8/jmbw3vDKTQfGW0cSzDtkvxixu9bUD6po9U6OEF04XLuukTDldFG34ccDscLkA8bYnZ7VjxP79cIC7tg==", - "dev": true, - "requires": { - "@cucumber/cucumber": "*" - } - }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -8662,35 +7745,6 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, - "@types/node-fetch": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", - "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", - "dev": true, - "requires": { - "@types/node": "*", - "form-data": "^3.0.0" - }, - "dependencies": { - "form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - } - } - }, - "@types/pubnub": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", - "integrity": "sha512-Ui58Xsn8/4Ty1hFW0t91ED6FKezzipjO+GEJviOdJdqp817+I5/WMfo5zBsDfjbZQWMqcdrktMauKpUqiIF1wA==", - "dev": true - }, "@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -8707,11 +7761,10 @@ "dev": true }, "@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", - "dev": true, - "peer": true + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true }, "@types/yargs": { "version": "16.0.4", @@ -8858,9 +7911,10 @@ } }, "acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==" + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", + "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "dev": true }, "acorn-jsx": { "version": "5.3.2", @@ -8872,7 +7926,8 @@ "acorn-walk": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true }, "after": { "version": "0.8.2", @@ -8881,11 +7936,21 @@ "dev": true }, "agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", "requires": { - "debug": "4" + "debug": "^4.3.4" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + } } }, "agentkeepalive": { @@ -8984,6 +8049,11 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + }, "asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -9070,6 +8140,11 @@ "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", "dev": true }, + "basic-ftp": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.3.tgz", + "integrity": "sha512-QHX8HLlncOLpy54mh+k/sWIFd0ThmRqwe9ZjELybGZK+tZ8rUb9VO0saKJUROTbE+KhzDUT7xziGpGrW8Kmd+g==" + }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -9079,13 +8154,6 @@ "tweetnacl": "^0.14.3" } }, - "becke-ch--regex--s0-0-v1--base--pl--lib": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", - "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==", - "dev": true, - "peer": true - }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -9194,13 +8262,13 @@ "bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -9312,19 +8380,18 @@ } }, "class-transformer": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", - "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", - "dev": true, - "peer": true + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true }, "cli-table3": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", - "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", + "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", "dev": true, "requires": { - "@colors/colors": "1.5.0", + "colors": "1.4.0", "string-width": "^4.2.0" } }, @@ -9457,21 +8524,15 @@ "dev": true }, "cookiejar": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", - "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" - }, - "core-js-pure": { - "version": "3.26.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", - "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", - "dev": true, - "peer": true + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" }, "core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true }, "create-require": { "version": "1.1.1", @@ -9501,158 +8562,6 @@ } } }, - "cucumber": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.7.tgz", - "integrity": "sha512-pN3AgWxHx8rOi+wOlqjASNETOjf3TgeyqhMNLQam7nSTXgQzju1oAmXkleRQRcXvpVvejcDHiZBLFSfBkqbYpA==", - "dev": true, - "peer": true, - "requires": { - "assertion-error-formatter": "^3.0.0", - "bluebird": "^3.4.1", - "cli-table3": "^0.5.1", - "colors": "^1.1.2", - "commander": "^3.0.1", - "cucumber-expressions": "^8.1.0", - "cucumber-tag-expressions": "^2.0.2", - "duration": "^0.2.1", - "escape-string-regexp": "^2.0.0", - "figures": "^3.0.0", - "gherkin": "5.0.0", - "glob": "^7.1.3", - "indent-string": "^4.0.0", - "is-generator": "^1.0.2", - "is-stream": "^2.0.0", - "knuth-shuffle-seeded": "^1.0.6", - "lodash": "^4.17.14", - "mz": "^2.4.0", - "progress": "^2.0.0", - "resolve": "^1.3.3", - "serialize-error": "^4.1.0", - "stack-chain": "^2.0.0", - "stacktrace-js": "^2.0.0", - "string-argv": "^0.3.0", - "title-case": "^2.1.1", - "util-arity": "^1.0.2", - "verror": "^1.9.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true, - "peer": true - }, - "cli-table3": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", - "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", - "dev": true, - "peer": true, - "requires": { - "colors": "^1.1.2", - "object-assign": "^4.1.0", - "string-width": "^2.1.1" - } - }, - "commander": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", - "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", - "dev": true, - "peer": true - }, - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true, - "peer": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", - "dev": true, - "peer": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "peer": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", - "dev": true, - "peer": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, - "cucumber-expressions": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/cucumber-expressions/-/cucumber-expressions-8.3.0.tgz", - "integrity": "sha512-cP2ya0EiorwXBC7Ll7Cj7NELYbasNv9Ty42L4u7sso9KruWemWG1ZiTq4PMqir3SNDSrbykoqI5wZgMbLEDjLQ==", - "dev": true, - "peer": true, - "requires": { - "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0", - "xregexp": "^4.2.4" - }, - "dependencies": { - "xregexp": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.4.1.tgz", - "integrity": "sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==", - "dev": true, - "peer": true, - "requires": { - "@babel/runtime-corejs3": "^7.12.1" - } - } - } - }, - "cucumber-pretty": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/cucumber-pretty/-/cucumber-pretty-6.0.1.tgz", - "integrity": "sha512-9uOIZ8x3lgCPROqYc7kqe2e7UrH5TZPZCdj5fVPze1XViG9yv8/8MnFsAnVINDYWVhiql8DJHb3UrZfIPHYH/A==", - "dev": true, - "requires": { - "cli-table3": "^0.6.0", - "colors": "^1.4.0", - "figures": "^3.2.0" - } - }, - "cucumber-tag-expressions": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/cucumber-tag-expressions/-/cucumber-tag-expressions-2.0.3.tgz", - "integrity": "sha512-+x5j1IfZrBtbvYHuoUX0rl4nUGxaey6Do9sM0CABmZfDCcWXuuRm1fQeCaklIYQgOFHQ6xOHvDSdkMHHpni6tQ==", - "dev": true, - "peer": true - }, - "cucumber-tsflow": { - "version": "4.0.0-rc.11", - "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-rc.11.tgz", - "integrity": "sha512-VK/RhJOOxS4KAH6UIkfLsDE2+H7OtP/+cwzx139gldqHP08hoYk/fMwOoXlGWXOOX2O3amJ6RTS0YMF2xCA8Bw==", - "dev": true, - "requires": { - "callsites": "^3.1.0", - "log4js": "^6.3.0", - "source-map-support": "^0.5.19", - "underscore": "^1.8.3" - } - }, "custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -9679,9 +8588,9 @@ } }, "data-uri-to-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", - "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==" + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-5.0.1.tgz", + "integrity": "sha512-a9l6T1qqDogvvnw0nKlfZzqsyikEBZBClF39V3TFoKhDtGBqHu2HkuomJc02j5zft8zrUaXEuoicLeW54RkzPg==" }, "date-format": { "version": "4.0.3", @@ -9729,7 +8638,8 @@ "deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true }, "deepmerge": { "version": "4.2.2", @@ -9747,14 +8657,13 @@ } }, "degenerator": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.2.tgz", - "integrity": "sha512-c0mef3SNQo56t6urUU6tdQAs+ThoD0o9B9MJ8HEt7NQcGEILCRFqQb7ZbP9JAv+QF1Ky5plydhMR/IrqWDm+TQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", + "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", "requires": { - "ast-types": "^0.13.2", - "escodegen": "^1.8.1", - "esprima": "^4.0.0", - "vm2": "^3.9.8" + "ast-types": "^0.13.4", + "escodegen": "^2.1.0", + "esprima": "^4.0.1" } }, "delayed-stream": { @@ -9765,7 +8674,17 @@ "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "dev": true + }, + "dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "requires": { + "asap": "^2.0.0", + "wrappy": "1" + } }, "di": { "version": "0.0.1", @@ -9934,12 +8853,12 @@ "dev": true }, "error-stack-parser": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", - "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.7.tgz", + "integrity": "sha512-chLOW0ZGRf4s8raLrDxa5sdkvPec5YdvwbFnqJme4rk0rFajP8mPtrDL1+I+CwrQDCjswDA5sREX7jYQDQs9vA==", "dev": true, "requires": { - "stackframe": "^1.3.4" + "stackframe": "^1.1.1" } }, "es5-ext": { @@ -10005,37 +8924,24 @@ "dev": true }, "escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", "requires": { "esprima": "^4.0.1", - "estraverse": "^4.2.0", + "estraverse": "^5.2.0", "esutils": "^2.0.2", - "optionator": "^0.8.1", "source-map": "~0.6.1" - }, - "dependencies": { - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" - } } }, "eslint": { - "version": "8.37.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", - "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", - "dev": true, - "requires": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.2", - "@eslint/js": "8.37.0", - "@humanwhocodes/config-array": "^0.11.8", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", + "integrity": "sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q==", + "dev": true, + "requires": { + "@eslint/eslintrc": "^1.1.0", + "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -10043,32 +8949,32 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-visitor-keys": "^3.4.0", - "espree": "^9.5.1", - "esquery": "^1.4.2", + "eslint-utils": "^3.0.0", + "eslint-visitor-keys": "^3.3.0", + "espree": "^9.3.1", + "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^6.0.1", + "globals": "^13.6.0", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", + "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", + "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" }, "dependencies": { "ansi-styles": { @@ -10126,6 +9032,15 @@ "is-glob": "^4.0.3" } }, + "globals": { + "version": "13.12.1", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", + "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -10238,20 +9153,20 @@ } }, "eslint-visitor-keys": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", - "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", + "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", "dev": true }, "espree": { - "version": "9.5.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", - "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", + "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", "dev": true, "requires": { - "acorn": "^8.8.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.0" + "acorn": "^8.7.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^3.3.0" } }, "esprima": { @@ -10260,9 +9175,9 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", - "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -10280,8 +9195,7 @@ "estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==" }, "estree-walker": { "version": "2.0.2", @@ -10404,7 +9318,8 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true }, "fast-safe-stringify": { "version": "2.1.1", @@ -10447,11 +9362,6 @@ "flat-cache": "^3.0.4" } }, - "file-uri-to-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", - "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==" - }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -10493,16 +9403,6 @@ } } }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, "flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -10549,9 +9449,25 @@ } }, "formidable": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", - "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", + "integrity": "sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==", + "requires": { + "dezalgo": "^1.0.4", + "hexoid": "^1.0.0", + "once": "^1.4.0", + "qs": "^6.11.0" + }, + "dependencies": { + "qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "requires": { + "side-channel": "^1.0.4" + } + } + } }, "fs-extra": { "version": "1.0.0", @@ -10572,48 +9488,15 @@ }, "fsevents": { "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, - "ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", - "requires": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "functional-red-black-tree": { "version": "1.0.1", @@ -10637,7 +9520,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -10645,18 +9527,24 @@ } }, "get-uri": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", - "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.1.tgz", + "integrity": "sha512-7ZqONUVqaabogsYNWlYj0t3YZaL6dhuEueZXGF+/YVmf6dHmaFg8/6psJKqhx9QykIDKzpGcy2cn4oV4YC7V/Q==", "requires": { - "@tootallnate/once": "1", - "data-uri-to-buffer": "3", - "debug": "4", - "file-uri-to-path": "2", - "fs-extra": "^8.1.0", - "ftp": "^0.3.10" + "basic-ftp": "^5.0.2", + "data-uri-to-buffer": "^5.0.1", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" }, "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -10670,7 +9558,7 @@ "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", "requires": { "graceful-fs": "^4.1.6" } @@ -10686,13 +9574,6 @@ "assert-plus": "^1.0.0" } }, - "gherkin": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-5.0.0.tgz", - "integrity": "sha512-Y+93z2Nh+TNIKuKEf+6M0FQrX/z0Yv9C2LFfc5NlcGJWRrrTeI/jOg2374y1FOw6ZYQ3RgJBezRkli7CLDubDA==", - "dev": true, - "peer": true - }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -10716,15 +9597,6 @@ "is-glob": "^4.0.1" } }, - "globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -10744,12 +9616,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, - "grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -10776,7 +9642,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -10813,8 +9678,7 @@ "has-symbols": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", - "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==" }, "has-tostringtag": { "version": "1.0.0", @@ -10849,10 +9713,16 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "hexoid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", + "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==" + }, "http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, "requires": { "depd": "~1.1.2", "inherits": "2.0.4", @@ -10873,13 +9743,22 @@ } }, "http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", + "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", "requires": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + } } }, "http-signature": { @@ -10894,11 +9773,11 @@ } }, "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", + "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", "requires": { - "agent-base": "6", + "agent-base": "^7.0.2", "debug": "4" } }, @@ -10914,6 +9793,7 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -10970,12 +9850,13 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" }, "is-arguments": { "version": "1.1.1", @@ -11053,12 +9934,6 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, - "is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true - }, "is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -11354,12 +10229,6 @@ } } }, - "js-sdsl": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", - "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", - "dev": true - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -11567,29 +10436,11 @@ "seed-random": "~2.2.0" } }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, "lil-uuid": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", "integrity": "sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY=" }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -11692,12 +10543,9 @@ } }, "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "requires": { - "yallist": "^3.0.2" - } + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==" }, "magic-string": { "version": "0.25.7", @@ -11874,6 +10722,16 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -11889,6 +10747,15 @@ "argparse": "^2.0.1" } }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -11904,6 +10771,30 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, "serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -12079,9 +10970,9 @@ } }, "node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "dev": true, "requires": { "whatwg-url": "^5.0.0" @@ -12105,6 +10996,11 @@ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, + "object-inspect": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==" + }, "object-is": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", @@ -12134,66 +11030,43 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1" } }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, "pac-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", - "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.0.tgz", + "integrity": "sha512-t4tRAMx0uphnZrio0S0Jw9zg3oDbz1zVhQ/Vy18FjLfP1XOLNUEjaVxYCYRI6NS+BsMBXKIzV6cTLOkO9AtywA==", "requires": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4", - "get-uri": "3", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "5", - "pac-resolver": "^5.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "5" + "@tootallnate/quickjs-emscripten": "^0.23.0", + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "get-uri": "^6.0.1", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "pac-resolver": "^7.0.0", + "socks-proxy-agent": "^8.0.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + } } }, "pac-resolver": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.0.tgz", - "integrity": "sha512-H+/A6KitiHNNW+bxBKREk2MCGSxljfqRX76NjummWEYIat7ldVXRU3dhRIE3iXZ0nvGBk6smv3nntxKkzRL8NA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", + "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", "requires": { - "degenerator": "^3.0.1", - "ip": "^1.1.5", - "netmask": "^2.0.1" + "degenerator": "^5.0.0", + "ip": "^1.1.8", + "netmask": "^2.0.2" } }, "pad-right": { @@ -12232,12 +11105,6 @@ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -12343,11 +11210,6 @@ "pinkie": "^2.0.0" } }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" - }, "prettier": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", @@ -12407,18 +11269,28 @@ "dev": true }, "proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", - "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.3.0.tgz", + "integrity": "sha512-0LdR757eTj/JfuU7TL2YCuAZnxWXu3tkJbg4Oq3geW/qFNT/32T0sp2HnZ9O0lMR4q3vwAt0+xCA8SR0WAD0og==", "requires": { - "agent-base": "^6.0.0", - "debug": "4", - "http-proxy-agent": "^4.0.0", - "https-proxy-agent": "^5.0.0", - "lru-cache": "^5.1.1", - "pac-proxy-agent": "^5.0.0", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^5.0.0" + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "lru-cache": "^7.14.1", + "pac-proxy-agent": "^7.0.0", + "proxy-from-env": "^1.1.0", + "socks-proxy-agent": "^8.0.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + } } }, "proxy-from-env": { @@ -12447,7 +11319,8 @@ "qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==" + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "dev": true }, "queue-microtask": { "version": "1.2.3", @@ -12480,6 +11353,7 @@ "version": "2.4.3", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", + "dev": true, "requires": { "bytes": "3.1.2", "http-errors": "1.8.1", @@ -12517,13 +11391,6 @@ "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", "dev": true }, - "regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true, - "peer": true - }, "regexp-match-indices": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regexp-match-indices/-/regexp-match-indices-1.0.2.tgz", @@ -12725,12 +11592,14 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true }, "seed-random": { "version": "2.2.0", @@ -12739,9 +11608,9 @@ "dev": true }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "requires": { "lru-cache": "^6.0.0" }, @@ -12753,30 +11622,6 @@ "requires": { "yallist": "^4.0.0" } - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - } - } - }, - "serialize-error": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", - "integrity": "sha512-5j9GgyGsP9vV9Uj1S0lDCvlsd+gc2LEPVK7HHHte7IyPwOD4lVQFeaX143gx3U5AnoCi+wbcb3mvaxVysjpxEw==", - "dev": true, - "peer": true, - "requires": { - "type-fest": "^0.3.0" - }, - "dependencies": { - "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", - "dev": true, - "peer": true } } }, @@ -12798,7 +11643,8 @@ "setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true }, "shebang-command": { "version": "2.0.0", @@ -12815,6 +11661,16 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, "sinon": { "version": "7.5.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", @@ -12975,22 +11831,39 @@ } }, "socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", + "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "requires": { - "ip": "^1.1.5", + "ip": "^2.0.0", "smart-buffer": "^4.2.0" + }, + "dependencies": { + "ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + } } }, "socks-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", - "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.1.tgz", + "integrity": "sha512-59EjPbbgg8U3x62hhKOFVAmySQUcfRQ4C7Q/D5sEHnZTQRrQlNKINks44DMR1gwXp0p4LaVIeccX2KHTTcHVqQ==", "requires": { - "agent-base": "^6.0.2", - "debug": "4", - "socks": "^2.3.3" + "agent-base": "^7.0.1", + "debug": "^4.3.4", + "socks": "^2.7.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + } } }, "source-map": { @@ -13000,9 +11873,9 @@ "devOptional": true }, "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -13071,9 +11944,9 @@ } }, "stackframe": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", - "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.1.tgz", + "integrity": "sha512-h88QkzREN/hy8eRdyNhhsO7RSJ5oyTqxxmmn0dzBIMUclZsjpfmrsg81vp8mjjAs2vAZ72nyWxRUwSwmh0e4xg==", "dev": true }, "stacktrace-gps": { @@ -13108,7 +11981,8 @@ "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true }, "streamroller": { "version": "3.0.2", @@ -13154,6 +12028,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, "requires": { "safe-buffer": "~5.1.0" } @@ -13206,54 +12081,50 @@ "dev": true }, "superagent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-6.1.0.tgz", - "integrity": "sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.1.2.tgz", + "integrity": "sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==", "requires": { "component-emitter": "^1.3.0", - "cookiejar": "^2.1.2", - "debug": "^4.1.1", - "fast-safe-stringify": "^2.0.7", - "form-data": "^3.0.0", - "formidable": "^1.2.2", + "cookiejar": "^2.1.4", + "debug": "^4.3.4", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.0", + "formidable": "^2.1.2", "methods": "^1.1.2", - "mime": "^2.4.6", - "qs": "^6.9.4", - "readable-stream": "^3.6.0", - "semver": "^7.3.2" + "mime": "2.6.0", + "qs": "^6.11.0", + "semver": "^7.3.8" }, "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, "form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "mime-types": "^2.1.12" } }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "side-channel": "^1.0.4" } } } }, - "superagent-proxy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/superagent-proxy/-/superagent-proxy-3.0.0.tgz", - "integrity": "sha512-wAlRInOeDFyd9pyonrkJspdRAxdLrcsZ6aSnS+8+nu4x1aXbz6FWSTT9M6Ibze+eG60szlL7JA8wEIV7bPWuyQ==", - "requires": { - "debug": "^4.3.2", - "proxy-agent": "^5.0.0" - } - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -13292,6 +12163,24 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", "dev": true + }, + "source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } } } }, @@ -13325,36 +12214,6 @@ "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "dev": true }, - "title-case": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", - "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", - "dev": true, - "peer": true, - "requires": { - "no-case": "^2.2.0", - "upper-case": "^1.0.3" - }, - "dependencies": { - "lower-case": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", - "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", - "dev": true, - "peer": true - }, - "no-case": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", - "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", - "dev": true, - "peer": true, - "requires": { - "lower-case": "^1.1.1" - } - } - } - }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -13382,7 +12241,8 @@ "toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true }, "tough-cookie": { "version": "2.5.0", @@ -13400,12 +12260,6 @@ "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "dev": true }, - "ts-dedent": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", - "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", - "dev": true - }, "ts-mocha": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-9.0.2.tgz", @@ -13447,12 +12301,12 @@ } }, "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", + "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", "dev": true, "requires": { - "@cspotcode/source-map-support": "^0.8.0", + "@cspotcode/source-map-support": "0.7.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -13463,7 +12317,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", + "v8-compile-cache-lib": "^3.0.0", "yn": "3.1.1" } }, @@ -13535,14 +12389,6 @@ "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", "dev": true }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "requires": { - "prelude-ls": "~1.1.2" - } - }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -13572,9 +12418,9 @@ "dev": true }, "typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "version": "4.5.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", + "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "dev": true }, "ua-parser-js": { @@ -13597,14 +12443,8 @@ "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, - "upper-case": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", - "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", - "dev": true, - "peer": true + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true }, "upper-case-first": { "version": "2.0.2", @@ -13633,7 +12473,8 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true }, "utils-merge": { "version": "1.0.1", @@ -13642,16 +12483,21 @@ "dev": true }, "uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", - "dev": true, - "peer": true + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + }, + "v8-compile-cache": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", + "dev": true }, "v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", + "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", "dev": true }, "verror": { @@ -13673,15 +12519,6 @@ } } }, - "vm2": { - "version": "3.9.8", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.8.tgz", - "integrity": "sha512-/1PYg/BwdKzMPo8maOZ0heT7DLI0DAFTm7YQaz/Lim9oIaFZsJs3EdtalvXuBfZwczNwsYhju75NW4d6E+4q+w==", - "requires": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - } - }, "void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -13722,7 +12559,8 @@ "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true }, "workerpool": { "version": "6.2.0", @@ -13770,8 +12608,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { "version": "7.4.6", @@ -13786,11 +12623,6 @@ "integrity": "sha512-3XfeQE/wNkvrIktn2Kf0869fC0BN6UpydVasGIeSm2B1Llihf7/0UfZM+eCkOw3P7bP4+qPgqhm7ZoxuJtFU0Q==", "dev": true }, - "xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=" - }, "y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", @@ -13798,9 +12630,9 @@ "dev": true }, "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "yargs": { "version": "15.4.1", @@ -13864,6 +12696,12 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, "yargs-parser": { "version": "18.1.3", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", From b57361fc927812df5fe8197ff0c448a834817800 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 8 Jan 2024 20:15:02 +0530 Subject: [PATCH 31/63] fix: package-lock --- package-lock.json | 3298 ++++++++++++++++++++++++++++++--------------- 1 file changed, 2230 insertions(+), 1068 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc645ef42..cf6948618 100644 --- a/package-lock.json +++ b/package-lock.json @@ -104,22 +104,37 @@ "node": ">=6.9.0" } }, - "node_modules/@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", + "node_modules/@babel/runtime-corejs3": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.0.tgz", + "integrity": "sha512-v1JH7PeAAGBEyTQM9TqojVl+b20zXtesFKCJHu50xMxZKD1fX0TKaKHPsZfFkXfs7D1M9M6Eeqg1FkJ3a0x2dA==", "dev": true, + "peer": true, + "dependencies": { + "core-js-pure": "^3.25.1", + "regenerator-runtime": "^0.13.10" + }, "engines": { - "node": ">= 12" + "node": ">=6.9.0" + } + }, + "node_modules/@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.1.90" } }, "node_modules/@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "dependencies": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" }, "engines": { "node": ">=12" @@ -134,6 +149,39 @@ "@cucumber/messages": "^16.0.0" } }, + "node_modules/@cucumber/create-meta/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/create-meta/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/create-meta/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/create-meta/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/cucumber": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/@cucumber/cucumber/-/cucumber-7.3.2.tgz", @@ -190,6 +238,54 @@ "regexp-match-indices": "1.0.2" } }, + "node_modules/@cucumber/cucumber/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/cucumber/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/cucumber/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/cucumber/node_modules/cli-table3": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", + "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0" + }, + "engines": { + "node": "10.* || >= 12.*" + }, + "optionalDependencies": { + "colors": "1.4.0" + } + }, + "node_modules/@cucumber/cucumber/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/gherkin": { "version": "19.0.3", "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-19.0.3.tgz", @@ -216,6 +312,82 @@ "gherkin-javascript": "bin/gherkin" } }, + "node_modules/@cucumber/gherkin-streams/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/gherkin-streams/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/gherkin-streams/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/gherkin-streams/node_modules/source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/@cucumber/gherkin-streams/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@cucumber/gherkin/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/gherkin/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/gherkin/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/gherkin/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/html-formatter": { "version": "15.0.2", "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-15.0.2.tgz", @@ -230,6 +402,49 @@ "cucumber-html-formatter": "bin/cucumber-html-formatter.js" } }, + "node_modules/@cucumber/html-formatter/node_modules/@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "dependencies": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "node_modules/@cucumber/html-formatter/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/html-formatter/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/html-formatter/node_modules/source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/@cucumber/html-formatter/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/@cucumber/message-streams": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", @@ -239,7 +454,7 @@ "@cucumber/messages": "^16.0.1" } }, - "node_modules/@cucumber/messages": { + "node_modules/@cucumber/message-streams/node_modules/@cucumber/messages": { "version": "16.0.1", "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", @@ -251,30 +466,119 @@ "uuid": "8.3.2" } }, + "node_modules/@cucumber/message-streams/node_modules/@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "node_modules/@cucumber/message-streams/node_modules/class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "node_modules/@cucumber/message-streams/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@cucumber/messages": { + "version": "21.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-21.0.1.tgz", + "integrity": "sha512-pGR7iURM4SF9Qp1IIpNiVQ77J9kfxMkPOEbyy+zRmGABnWWCsqMpJdfHeh9Mb3VskemVw85++e15JT0PYdcR3g==", + "dev": true, + "peer": true, + "dependencies": { + "@types/uuid": "8.3.4", + "class-transformer": "0.5.1", + "reflect-metadata": "0.1.13", + "uuid": "9.0.0" + } + }, + "node_modules/@cucumber/pretty-formatter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", + "integrity": "sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==", + "dev": true, + "dependencies": { + "ansi-styles": "^5.0.0", + "cli-table3": "^0.6.0", + "figures": "^3.2.0", + "ts-dedent": "^2.0.0" + }, + "peerDependencies": { + "@cucumber/cucumber": ">=7.0.0", + "@cucumber/messages": "*" + } + }, + "node_modules/@cucumber/pretty-formatter/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/@cucumber/tag-expressions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@cucumber/tag-expressions/-/tag-expressions-3.0.1.tgz", "integrity": "sha512-OGCXaJ1BQXmQ5b9pw+JYsBGumK2/LPZiLmbj1o1JFVeSNs2PY8WPQFSyXrskhrHz5Nd/6lYg7lvGMtFHOncC4w==", "dev": true }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", + "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.1.0.tgz", - "integrity": "sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", + "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", - "ignore": "^4.0.6", + "espree": "^9.5.1", + "globals": "^13.19.0", + "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/eslintrc/node_modules/argparse": { @@ -283,30 +587,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/eslintrc/node_modules/ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, "node_modules/@eslint/eslintrc/node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -319,20 +599,42 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/@eslint/js": { + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", + "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", - "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.4" + "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -425,6 +727,31 @@ "node": ">=8" } }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -590,10 +917,13 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, - "node_modules/@tootallnate/quickjs-emscripten": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", - "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" + "node_modules/@tootallnate/once": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", + "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", + "engines": { + "node": ">= 6" + } }, "node_modules/@tsconfig/node10": { "version": "1.0.8", @@ -619,6 +949,22 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, + "node_modules/@types/chai": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", + "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", + "dev": true + }, + "node_modules/@types/cucumber": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/cucumber/-/cucumber-7.0.0.tgz", + "integrity": "sha512-cr5NN8/jmbw3vDKTQfGW0cSzDtkvxixu9bUD6po9U6OEF04XLuukTDldFG34ccDscLkA8bYnZ7VjxP79cIC7tg==", + "deprecated": "This is a stub types definition. @cucumber/cucumber provides its own type definitions, so you do not need this installed.", + "dev": true, + "dependencies": { + "@cucumber/cucumber": "*" + } + }, "node_modules/@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -693,6 +1039,36 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, + "node_modules/@types/node-fetch": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", + "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", + "dev": true, + "dependencies": { + "@types/node": "*", + "form-data": "^3.0.0" + } + }, + "node_modules/@types/node-fetch/node_modules/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@types/pubnub": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", + "integrity": "sha512-Ui58Xsn8/4Ty1hFW0t91ED6FKezzipjO+GEJviOdJdqp817+I5/WMfo5zBsDfjbZQWMqcdrktMauKpUqiIF1wA==", + "dev": true + }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -709,10 +1085,11 @@ "dev": true }, "node_modules/@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", + "dev": true, + "peer": true }, "node_modules/@types/yargs": { "version": "16.0.4", @@ -955,10 +1332,9 @@ } }, "node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", - "dev": true, + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", "bin": { "acorn": "bin/acorn" }, @@ -979,7 +1355,6 @@ "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -991,30 +1366,14 @@ "dev": true }, "node_modules/agent-base": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", - "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", - "dependencies": { - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/agent-base/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "dependencies": { - "ms": "2.1.2" + "debug": "4" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 6.0.0" } }, "node_modules/agentkeepalive": { @@ -1136,12 +1495,7 @@ "dev": true, "engines": { "node": ">=0.10.0" - } - }, - "node_modules/asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + } }, "node_modules/asn1": { "version": "0.2.6", @@ -1261,14 +1615,6 @@ "node": "^4.5.0 || >= 5.9" } }, - "node_modules/basic-ftp": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.3.tgz", - "integrity": "sha512-QHX8HLlncOLpy54mh+k/sWIFd0ThmRqwe9ZjELybGZK+tZ8rUb9VO0saKJUROTbE+KhzDUT7xziGpGrW8Kmd+g==", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -1278,6 +1624,13 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==", + "dev": true, + "peer": true + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -1417,7 +1770,6 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "dev": true, "engines": { "node": ">= 0.8" } @@ -1426,6 +1778,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -1569,15 +1922,16 @@ } }, "node_modules/class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", + "dev": true, + "peer": true }, "node_modules/cli-table3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", - "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", + "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", "dev": true, "dependencies": { "string-width": "^4.2.0" @@ -1586,7 +1940,7 @@ "node": "10.* || >= 12.*" }, "optionalDependencies": { - "colors": "1.4.0" + "@colors/colors": "1.5.0" } }, "node_modules/cliui": { @@ -1737,15 +2091,26 @@ } }, "node_modules/cookiejar": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", - "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" + }, + "node_modules/core-js-pure": { + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", + "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", + "dev": true, + "hasInstallScript": true, + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "node_modules/create-require": { "version": "1.1.1", @@ -1782,6 +2147,188 @@ "node": ">= 8" } }, + "node_modules/cucumber": { + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.7.tgz", + "integrity": "sha512-pN3AgWxHx8rOi+wOlqjASNETOjf3TgeyqhMNLQam7nSTXgQzju1oAmXkleRQRcXvpVvejcDHiZBLFSfBkqbYpA==", + "deprecated": "Cucumber is publishing new releases under @cucumber/cucumber", + "dev": true, + "peer": true, + "dependencies": { + "assertion-error-formatter": "^3.0.0", + "bluebird": "^3.4.1", + "cli-table3": "^0.5.1", + "colors": "^1.1.2", + "commander": "^3.0.1", + "cucumber-expressions": "^8.1.0", + "cucumber-tag-expressions": "^2.0.2", + "duration": "^0.2.1", + "escape-string-regexp": "^2.0.0", + "figures": "^3.0.0", + "gherkin": "5.0.0", + "glob": "^7.1.3", + "indent-string": "^4.0.0", + "is-generator": "^1.0.2", + "is-stream": "^2.0.0", + "knuth-shuffle-seeded": "^1.0.6", + "lodash": "^4.17.14", + "mz": "^2.4.0", + "progress": "^2.0.0", + "resolve": "^1.3.3", + "serialize-error": "^4.1.0", + "stack-chain": "^2.0.0", + "stacktrace-js": "^2.0.0", + "string-argv": "^0.3.0", + "title-case": "^2.1.1", + "util-arity": "^1.0.2", + "verror": "^1.9.0" + }, + "bin": { + "cucumber-js": "bin/cucumber-js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cucumber-expressions": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/cucumber-expressions/-/cucumber-expressions-8.3.0.tgz", + "integrity": "sha512-cP2ya0EiorwXBC7Ll7Cj7NELYbasNv9Ty42L4u7sso9KruWemWG1ZiTq4PMqir3SNDSrbykoqI5wZgMbLEDjLQ==", + "deprecated": "This package is now published under @cucumber/cucumber-expressions", + "dev": true, + "peer": true, + "dependencies": { + "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0", + "xregexp": "^4.2.4" + } + }, + "node_modules/cucumber-expressions/node_modules/xregexp": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.4.1.tgz", + "integrity": "sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/runtime-corejs3": "^7.12.1" + } + }, + "node_modules/cucumber-pretty": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cucumber-pretty/-/cucumber-pretty-6.0.1.tgz", + "integrity": "sha512-9uOIZ8x3lgCPROqYc7kqe2e7UrH5TZPZCdj5fVPze1XViG9yv8/8MnFsAnVINDYWVhiql8DJHb3UrZfIPHYH/A==", + "dev": true, + "dependencies": { + "cli-table3": "^0.6.0", + "colors": "^1.4.0", + "figures": "^3.2.0" + }, + "peerDependencies": { + "cucumber": ">=6.0.0 <7.0.0" + } + }, + "node_modules/cucumber-tag-expressions": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cucumber-tag-expressions/-/cucumber-tag-expressions-2.0.3.tgz", + "integrity": "sha512-+x5j1IfZrBtbvYHuoUX0rl4nUGxaey6Do9sM0CABmZfDCcWXuuRm1fQeCaklIYQgOFHQ6xOHvDSdkMHHpni6tQ==", + "dev": true, + "peer": true + }, + "node_modules/cucumber-tsflow": { + "version": "4.0.0-rc.11", + "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-rc.11.tgz", + "integrity": "sha512-VK/RhJOOxS4KAH6UIkfLsDE2+H7OtP/+cwzx139gldqHP08hoYk/fMwOoXlGWXOOX2O3amJ6RTS0YMF2xCA8Bw==", + "dev": true, + "dependencies": { + "callsites": "^3.1.0", + "log4js": "^6.3.0", + "source-map-support": "^0.5.19", + "underscore": "^1.8.3" + }, + "peerDependencies": { + "@cucumber/cucumber": ">7.0.0-rc || >7.0.0" + } + }, + "node_modules/cucumber/node_modules/ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/cucumber/node_modules/cli-table3": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", + "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", + "dev": true, + "peer": true, + "dependencies": { + "object-assign": "^4.1.0", + "string-width": "^2.1.1" + }, + "engines": { + "node": ">=6" + }, + "optionalDependencies": { + "colors": "^1.1.2" + } + }, + "node_modules/cucumber/node_modules/commander": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", + "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", + "dev": true, + "peer": true + }, + "node_modules/cucumber/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/cucumber/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/cucumber/node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "peer": true, + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/cucumber/node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "peer": true, + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -1811,11 +2358,11 @@ } }, "node_modules/data-uri-to-buffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-5.0.1.tgz", - "integrity": "sha512-a9l6T1qqDogvvnw0nKlfZzqsyikEBZBClF39V3TFoKhDtGBqHu2HkuomJc02j5zft8zrUaXEuoicLeW54RkzPg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", + "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==", "engines": { - "node": ">= 14" + "node": ">= 6" } }, "node_modules/date-format": { @@ -1884,8 +2431,7 @@ "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" }, "node_modules/deepmerge": { "version": "4.2.2", @@ -1909,16 +2455,17 @@ } }, "node_modules/degenerator": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", - "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.2.tgz", + "integrity": "sha512-c0mef3SNQo56t6urUU6tdQAs+ThoD0o9B9MJ8HEt7NQcGEILCRFqQb7ZbP9JAv+QF1Ky5plydhMR/IrqWDm+TQ==", "dependencies": { - "ast-types": "^0.13.4", - "escodegen": "^2.1.0", - "esprima": "^4.0.1" + "ast-types": "^0.13.2", + "escodegen": "^1.8.1", + "esprima": "^4.0.0", + "vm2": "^3.9.8" }, "engines": { - "node": ">= 14" + "node": ">= 6" } }, "node_modules/delayed-stream": { @@ -1933,20 +2480,10 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true, "engines": { "node": ">= 0.6" } }, - "node_modules/dezalgo": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", - "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", - "dependencies": { - "asap": "^2.0.0", - "wrappy": "1" - } - }, "node_modules/di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -2132,12 +2669,12 @@ "dev": true }, "node_modules/error-stack-parser": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.7.tgz", - "integrity": "sha512-chLOW0ZGRf4s8raLrDxa5sdkvPec5YdvwbFnqJme4rk0rFajP8mPtrDL1+I+CwrQDCjswDA5sREX7jYQDQs9vA==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", + "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", "dev": true, "dependencies": { - "stackframe": "^1.1.1" + "stackframe": "^1.3.4" } }, "node_modules/es5-ext": { @@ -2209,33 +2746,47 @@ } }, "node_modules/escodegen": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", - "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", "dependencies": { "esprima": "^4.0.1", - "estraverse": "^5.2.0", - "esutils": "^2.0.2" + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1" }, "bin": { "escodegen": "bin/escodegen.js", "esgenerate": "bin/esgenerate.js" }, "engines": { - "node": ">=6.0" + "node": ">=4.0" }, "optionalDependencies": { "source-map": "~0.6.1" } }, + "node_modules/escodegen/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "engines": { + "node": ">=4.0" + } + }, "node_modules/eslint": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", - "integrity": "sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q==", - "dev": true, - "dependencies": { - "@eslint/eslintrc": "^1.1.0", - "@humanwhocodes/config-array": "^0.9.2", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", + "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.2", + "@eslint/js": "8.37.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -2243,32 +2794,32 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", - "esquery": "^1.4.0", + "eslint-visitor-keys": "^3.4.0", + "espree": "^9.5.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" @@ -2358,12 +2909,15 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", + "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/ansi-styles": { @@ -2445,21 +2999,6 @@ "node": ">=10.13.0" } }, - "node_modules/eslint/node_modules/globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/eslint/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -2545,17 +3084,20 @@ } }, "node_modules/espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", + "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", "dev": true, "dependencies": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.3.0" + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/esprima": { @@ -2571,9 +3113,9 @@ } }, "node_modules/esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { "estraverse": "^5.1.0" @@ -2598,6 +3140,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, "engines": { "node": ">=4.0" } @@ -2734,8 +3277,7 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, "node_modules/fast-safe-stringify": { "version": "2.1.1", @@ -2787,6 +3329,14 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-uri-to-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", + "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==", + "engines": { + "node": ">= 6" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -2832,6 +3382,22 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -2904,33 +3470,14 @@ } }, "node_modules/formidable": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", - "integrity": "sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==", - "dependencies": { - "dezalgo": "^1.0.4", - "hexoid": "^1.0.0", - "once": "^1.4.0", - "qs": "^6.11.0" - }, + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", + "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==", + "deprecated": "Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau", "funding": { "url": "https://ko-fi.com/tunnckoCore/commissions" } }, - "node_modules/formidable/node_modules/qs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", - "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", - "dependencies": { - "side-channel": "^1.0.4" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/fs-extra": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", @@ -2962,10 +3509,44 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/ftp": { + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", + "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", + "dependencies": { + "readable-stream": "1.1.x", + "xregexp": "2.0.0" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/ftp/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "node_modules/ftp/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/ftp/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "node_modules/functional-red-black-tree": { "version": "1.0.1", @@ -2995,6 +3576,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -3005,33 +3587,19 @@ } }, "node_modules/get-uri": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.1.tgz", - "integrity": "sha512-7ZqONUVqaabogsYNWlYj0t3YZaL6dhuEueZXGF+/YVmf6dHmaFg8/6psJKqhx9QykIDKzpGcy2cn4oV4YC7V/Q==", - "dependencies": { - "basic-ftp": "^5.0.2", - "data-uri-to-buffer": "^5.0.1", - "debug": "^4.3.4", - "fs-extra": "^8.1.0" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/get-uri/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", + "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", "dependencies": { - "ms": "2.1.2" + "@tootallnate/once": "1", + "data-uri-to-buffer": "3", + "debug": "4", + "file-uri-to-path": "2", + "fs-extra": "^8.1.0", + "ftp": "^0.3.10" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 6" } }, "node_modules/get-uri/node_modules/fs-extra": { @@ -3050,7 +3618,7 @@ "node_modules/get-uri/node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -3064,6 +3632,17 @@ "assert-plus": "^1.0.0" } }, + "node_modules/gherkin": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-5.0.0.tgz", + "integrity": "sha512-Y+93z2Nh+TNIKuKEf+6M0FQrX/z0Yv9C2LFfc5NlcGJWRrrTeI/jOg2374y1FOw6ZYQ3RgJBezRkli7CLDubDA==", + "deprecated": "This package is now published under @cucumber/gherkin", + "dev": true, + "peer": true, + "bin": { + "gherkin-javascript": "bin/gherkin" + } + }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -3093,7 +3672,22 @@ "is-glob": "^4.0.1" }, "engines": { - "node": ">= 6" + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globby": { @@ -3121,6 +3715,12 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, + "node_modules/grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, "node_modules/growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -3157,6 +3757,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -3198,6 +3799,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true, "engines": { "node": ">= 0.4" }, @@ -3251,19 +3853,10 @@ "he": "bin/he" } }, - "node_modules/hexoid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", - "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==", - "engines": { - "node": ">=8" - } - }, "node_modules/http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "dev": true, "dependencies": { "depd": "~1.1.2", "inherits": "2.0.4", @@ -3290,31 +3883,16 @@ } }, "node_modules/http-proxy-agent": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", - "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", - "dependencies": { - "agent-base": "^7.1.0", - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/http-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", + "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", "dependencies": { - "ms": "2.1.2" + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 6" } }, "node_modules/http-signature": { @@ -3333,15 +3911,15 @@ } }, "node_modules/https-proxy-agent": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", - "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", "dependencies": { - "agent-base": "^7.0.2", + "agent-base": "6", "debug": "4" }, "engines": { - "node": ">= 14" + "node": ">= 6" } }, "node_modules/humanize-ms": { @@ -3356,7 +3934,6 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -3445,13 +4022,12 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/ip": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", - "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" }, "node_modules/is-arguments": { "version": "1.1.1", @@ -3559,6 +4135,15 @@ "node": ">=0.12.0" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -3957,6 +4542,16 @@ "node": ">=8" } }, + "node_modules/js-sdsl": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", + "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4190,11 +4785,38 @@ "seed-random": "~2.2.0" } }, + "node_modules/levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dependencies": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/lil-uuid": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", "integrity": "sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY=" }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -4325,11 +4947,11 @@ } }, "node_modules/lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", - "engines": { - "node": ">=12" + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dependencies": { + "yallist": "^3.0.2" } }, "node_modules/magic-string": { @@ -4566,22 +5188,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/mocha/node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -4603,21 +5209,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/mocha/node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/mocha/node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -4636,45 +5227,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "node_modules/mocha/node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/mocha/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/mocha/node_modules/serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -4886,9 +5438,9 @@ } }, "node_modules/node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", "dev": true, "dependencies": { "whatwg-url": "^5.0.0" @@ -4932,14 +5484,6 @@ "node": ">=0.10.0" } }, - "node_modules/object-inspect": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/object-is": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", @@ -4981,55 +5525,87 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "dependencies": { "wrappy": "1" } }, - "node_modules/pac-proxy-agent": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.0.tgz", - "integrity": "sha512-t4tRAMx0uphnZrio0S0Jw9zg3oDbz1zVhQ/Vy18FjLfP1XOLNUEjaVxYCYRI6NS+BsMBXKIzV6cTLOkO9AtywA==", + "node_modules/optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", "dependencies": { - "@tootallnate/quickjs-emscripten": "^0.23.0", - "agent-base": "^7.0.2", - "debug": "^4.3.4", - "get-uri": "^6.0.1", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.0", - "pac-resolver": "^7.0.0", - "socks-proxy-agent": "^8.0.1" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" }, "engines": { - "node": ">= 14" + "node": ">= 0.8.0" } }, - "node_modules/pac-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, "dependencies": { - "ms": "2.1.2" + "yocto-queue": "^0.1.0" }, "engines": { - "node": ">=6.0" + "node": ">=10" }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pac-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", + "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", + "dependencies": { + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4", + "get-uri": "3", + "http-proxy-agent": "^4.0.1", + "https-proxy-agent": "5", + "pac-resolver": "^5.0.0", + "raw-body": "^2.2.0", + "socks-proxy-agent": "5" + }, + "engines": { + "node": ">= 8" } }, "node_modules/pac-resolver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", - "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.0.tgz", + "integrity": "sha512-H+/A6KitiHNNW+bxBKREk2MCGSxljfqRX76NjummWEYIat7ldVXRU3dhRIE3iXZ0nvGBk6smv3nntxKkzRL8NA==", "dependencies": { - "degenerator": "^5.0.0", - "ip": "^1.1.8", - "netmask": "^2.0.2" + "degenerator": "^3.0.1", + "ip": "^1.1.5", + "netmask": "^2.0.1" }, "engines": { - "node": ">= 14" + "node": ">= 8" } }, "node_modules/pad-right": { @@ -5077,6 +5653,15 @@ "node": ">= 0.8" } }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -5210,6 +5795,14 @@ "node": ">=0.10.0" } }, + "node_modules/prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/prettier": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", @@ -5291,37 +5884,21 @@ ] }, "node_modules/proxy-agent": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.3.0.tgz", - "integrity": "sha512-0LdR757eTj/JfuU7TL2YCuAZnxWXu3tkJbg4Oq3geW/qFNT/32T0sp2HnZ9O0lMR4q3vwAt0+xCA8SR0WAD0og==", - "dependencies": { - "agent-base": "^7.0.2", - "debug": "^4.3.4", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.0", - "lru-cache": "^7.14.1", - "pac-proxy-agent": "^7.0.0", - "proxy-from-env": "^1.1.0", - "socks-proxy-agent": "^8.0.1" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", + "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", "dependencies": { - "ms": "2.1.2" + "agent-base": "^6.0.0", + "debug": "4", + "http-proxy-agent": "^4.0.0", + "https-proxy-agent": "^5.0.0", + "lru-cache": "^5.1.1", + "pac-proxy-agent": "^5.0.0", + "proxy-from-env": "^1.0.0", + "socks-proxy-agent": "^5.0.0" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 8" } }, "node_modules/proxy-from-env": { @@ -5357,7 +5934,6 @@ "version": "6.9.7", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", - "dev": true, "engines": { "node": ">=0.6" }, @@ -5413,7 +5989,6 @@ "version": "2.4.3", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", - "dev": true, "dependencies": { "bytes": "3.1.2", "http-errors": "1.8.1", @@ -5457,6 +6032,13 @@ "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", "dev": true }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "dev": true, + "peer": true + }, "node_modules/regexp-match-indices": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regexp-match-indices/-/regexp-match-indices-1.0.2.tgz", @@ -5739,14 +6321,12 @@ "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/seed-random": { "version": "2.2.0", @@ -5755,9 +6335,9 @@ "dev": true }, "node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5779,6 +6359,34 @@ "node": ">=10" } }, + "node_modules/semver/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/serialize-error": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", + "integrity": "sha512-5j9GgyGsP9vV9Uj1S0lDCvlsd+gc2LEPVK7HHHte7IyPwOD4lVQFeaX143gx3U5AnoCi+wbcb3mvaxVysjpxEw==", + "dev": true, + "peer": true, + "dependencies": { + "type-fest": "^0.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/serialize-error/node_modules/type-fest": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", + "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=6" + } + }, "node_modules/serialize-javascript": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", @@ -5797,8 +6405,7 @@ "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "dev": true + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "node_modules/shebang-command": { "version": "2.0.0", @@ -5814,24 +6421,11 @@ }, "node_modules/shebang-regex": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dependencies": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" } }, "node_modules/sinon": { @@ -6001,11 +6595,11 @@ } }, "node_modules/socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", + "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", "dependencies": { - "ip": "^2.0.0", + "ip": "^1.1.5", "smart-buffer": "^4.2.0" }, "engines": { @@ -6014,39 +6608,18 @@ } }, "node_modules/socks-proxy-agent": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.1.tgz", - "integrity": "sha512-59EjPbbgg8U3x62hhKOFVAmySQUcfRQ4C7Q/D5sEHnZTQRrQlNKINks44DMR1gwXp0p4LaVIeccX2KHTTcHVqQ==", - "dependencies": { - "agent-base": "^7.0.1", - "debug": "^4.3.4", - "socks": "^2.7.1" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/socks-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", + "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", "dependencies": { - "ms": "2.1.2" + "agent-base": "^6.0.2", + "debug": "4", + "socks": "^2.3.3" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 6" } }, - "node_modules/socks/node_modules/ip": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", - "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -6057,9 +6630,9 @@ } }, "node_modules/source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, "dependencies": { "buffer-from": "^1.0.0", @@ -6140,9 +6713,9 @@ } }, "node_modules/stackframe": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.1.tgz", - "integrity": "sha512-h88QkzREN/hy8eRdyNhhsO7RSJ5oyTqxxmmn0dzBIMUclZsjpfmrsg81vp8mjjAs2vAZ72nyWxRUwSwmh0e4xg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", + "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==", "dev": true }, "node_modules/stacktrace-gps": { @@ -6179,7 +6752,6 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true, "engines": { "node": ">= 0.6" } @@ -6237,7 +6809,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, "dependencies": { "safe-buffer": "~5.1.0" } @@ -6306,45 +6877,46 @@ } }, "node_modules/superagent": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.1.2.tgz", - "integrity": "sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-6.1.0.tgz", + "integrity": "sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==", + "deprecated": "Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at .", "dependencies": { "component-emitter": "^1.3.0", - "cookiejar": "^2.1.4", - "debug": "^4.3.4", - "fast-safe-stringify": "^2.1.1", - "form-data": "^4.0.0", - "formidable": "^2.1.2", + "cookiejar": "^2.1.2", + "debug": "^4.1.1", + "fast-safe-stringify": "^2.0.7", + "form-data": "^3.0.0", + "formidable": "^1.2.2", "methods": "^1.1.2", - "mime": "2.6.0", - "qs": "^6.11.0", - "semver": "^7.3.8" + "mime": "^2.4.6", + "qs": "^6.9.4", + "readable-stream": "^3.6.0", + "semver": "^7.3.2" }, "engines": { - "node": ">=6.4.0 <13 || >=14" + "node": ">= 7.0.0" } }, - "node_modules/superagent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "node_modules/superagent-proxy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/superagent-proxy/-/superagent-proxy-3.0.0.tgz", + "integrity": "sha512-wAlRInOeDFyd9pyonrkJspdRAxdLrcsZ6aSnS+8+nu4x1aXbz6FWSTT9M6Ibze+eG60szlL7JA8wEIV7bPWuyQ==", "dependencies": { - "ms": "2.1.2" + "debug": "^4.3.2", + "proxy-agent": "^5.0.0" }, "engines": { - "node": ">=6.0" + "node": ">=6" }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "peerDependencies": { + "superagent": ">= 0.15.4 || 1 || 2 || 3" } }, "node_modules/superagent/node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -6354,18 +6926,17 @@ "node": ">= 6" } }, - "node_modules/superagent/node_modules/qs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", - "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "node_modules/superagent/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dependencies": { - "side-channel": "^1.0.4" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" }, "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "node": ">= 6" } }, "node_modules/supports-color": { @@ -6425,25 +6996,6 @@ "node": ">= 8" } }, - "node_modules/terser/node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/terser/node_modules/source-map-support/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -6477,6 +7029,34 @@ "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "dev": true }, + "node_modules/title-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", + "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", + "dev": true, + "peer": true, + "dependencies": { + "no-case": "^2.2.0", + "upper-case": "^1.0.3" + } + }, + "node_modules/title-case/node_modules/lower-case": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", + "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", + "dev": true, + "peer": true + }, + "node_modules/title-case/node_modules/no-case": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", + "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", + "dev": true, + "peer": true, + "dependencies": { + "lower-case": "^1.1.1" + } + }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -6511,7 +7091,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "dev": true, "engines": { "node": ">=0.6" } @@ -6535,6 +7114,15 @@ "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "dev": true }, + "node_modules/ts-dedent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", + "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", + "dev": true, + "engines": { + "node": ">=6.10" + } + }, "node_modules/ts-mocha": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-9.0.2.tgz", @@ -6597,12 +7185,12 @@ } }, "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -6613,7 +7201,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "bin": { @@ -6715,6 +7303,17 @@ "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", "dev": true }, + "node_modules/type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dependencies": { + "prelude-ls": "~1.1.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -6756,9 +7355,9 @@ "dev": true }, "node_modules/typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -6795,11 +7394,17 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true, "engines": { "node": ">= 0.8" } }, + "node_modules/upper-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", + "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", + "dev": true, + "peer": true + }, "node_modules/upper-case-first": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", @@ -6827,8 +7432,7 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "node_modules/utils-merge": { "version": "1.0.1", @@ -6840,24 +7444,19 @@ } }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "dev": true, + "peer": true, "bin": { "uuid": "dist/bin/uuid" } }, - "node_modules/v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true - }, "node_modules/v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "node_modules/verror": { @@ -6880,6 +7479,21 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "node_modules/vm2": { + "version": "3.9.8", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.8.tgz", + "integrity": "sha512-/1PYg/BwdKzMPo8maOZ0heT7DLI0DAFTm7YQaz/Lim9oIaFZsJs3EdtalvXuBfZwczNwsYhju75NW4d6E+4q+w==", + "dependencies": { + "acorn": "^8.7.0", + "acorn-walk": "^8.2.0" + }, + "bin": { + "vm2": "bin/vm2" + }, + "engines": { + "node": ">=6.0" + } + }, "node_modules/void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -6927,7 +7541,6 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -6988,7 +7601,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "node_modules/ws": { "version": "7.4.6", @@ -7020,6 +7634,14 @@ "node": ">=0.4.0" } }, + "node_modules/xregexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", + "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=", + "engines": { + "node": "*" + } + }, "node_modules/y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", @@ -7027,9 +7649,9 @@ "dev": true }, "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "node_modules/yargs": { "version": "15.4.1", @@ -7162,15 +7784,6 @@ "node": ">=6" } }, - "node_modules/yargs/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/yargs/node_modules/yargs-parser": { "version": "18.1.3", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", @@ -7249,19 +7862,31 @@ "js-tokens": "^4.0.0" } }, - "@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true + "@babel/runtime-corejs3": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.0.tgz", + "integrity": "sha512-v1JH7PeAAGBEyTQM9TqojVl+b20zXtesFKCJHu50xMxZKD1fX0TKaKHPsZfFkXfs7D1M9M6Eeqg1FkJ3a0x2dA==", + "dev": true, + "peer": true, + "requires": { + "core-js-pure": "^3.25.1", + "regenerator-runtime": "^0.13.10" + } + }, + "@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true, + "optional": true }, "@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "requires": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" } }, "@cucumber/create-meta": { @@ -7271,6 +7896,38 @@ "dev": true, "requires": { "@cucumber/messages": "^16.0.0" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/cucumber": { @@ -7312,6 +7969,48 @@ "tmp": "^0.2.1", "util-arity": "^1.1.0", "verror": "^1.10.0" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "cli-table3": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", + "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "dev": true, + "requires": { + "colors": "1.4.0", + "string-width": "^4.2.0" + } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/cucumber-expressions": { @@ -7331,6 +8030,38 @@ "requires": { "@cucumber/message-streams": "^2.0.0", "@cucumber/messages": "^16.0.1" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/gherkin-streams": { @@ -7344,6 +8075,48 @@ "@cucumber/messages": "^16.0.0", "commander": "7.2.0", "source-map-support": "0.5.19" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, "@cucumber/html-formatter": { @@ -7355,27 +8128,122 @@ "@cucumber/messages": "^16.0.1", "commander": "7.2.0", "source-map-support": "0.5.19" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "source-map-support": { + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } + } + }, + "@cucumber/message-streams": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", + "integrity": "sha512-Yh3mw3qv6QL9NI/ihkZF8V9MX2GbnR6oktv34kC3uAbrQy9d/b2SZ3HNjG3J9JQqpV4B7Om3SPElJYIeo66TrA==", + "dev": true, + "requires": { + "@cucumber/messages": "^16.0.1" + }, + "dependencies": { + "@cucumber/messages": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", + "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "dev": true, + "requires": { + "@types/uuid": "8.3.0", + "class-transformer": "0.4.0", + "reflect-metadata": "0.1.13", + "uuid": "8.3.2" + } + }, + "@types/uuid": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "dev": true + }, + "class-transformer": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", + "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + } } }, - "@cucumber/message-streams": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", - "integrity": "sha512-Yh3mw3qv6QL9NI/ihkZF8V9MX2GbnR6oktv34kC3uAbrQy9d/b2SZ3HNjG3J9JQqpV4B7Om3SPElJYIeo66TrA==", + "@cucumber/messages": { + "version": "21.0.1", + "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-21.0.1.tgz", + "integrity": "sha512-pGR7iURM4SF9Qp1IIpNiVQ77J9kfxMkPOEbyy+zRmGABnWWCsqMpJdfHeh9Mb3VskemVw85++e15JT0PYdcR3g==", "dev": true, + "peer": true, "requires": { - "@cucumber/messages": "^16.0.1" + "@types/uuid": "8.3.4", + "class-transformer": "0.5.1", + "reflect-metadata": "0.1.13", + "uuid": "9.0.0" } }, - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", + "@cucumber/pretty-formatter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", + "integrity": "sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==", "dev": true, "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" + "ansi-styles": "^5.0.0", + "cli-table3": "^0.6.0", + "figures": "^3.2.0", + "ts-dedent": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true + } } }, "@cucumber/tag-expressions": { @@ -7384,20 +8252,35 @@ "integrity": "sha512-OGCXaJ1BQXmQ5b9pw+JYsBGumK2/LPZiLmbj1o1JFVeSNs2PY8WPQFSyXrskhrHz5Nd/6lYg7lvGMtFHOncC4w==", "dev": true }, + "@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.3.0" + } + }, + "@eslint-community/regexpp": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", + "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", + "dev": true + }, "@eslint/eslintrc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.1.0.tgz", - "integrity": "sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", + "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", - "ignore": "^4.0.6", + "espree": "^9.5.1", + "globals": "^13.19.0", + "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "dependencies": { @@ -7407,21 +8290,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, "js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -7433,17 +8301,29 @@ } } }, + "@eslint/js": { + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", + "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", + "dev": true + }, "@humanwhocodes/config-array": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", - "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", + "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.4" + "minimatch": "^3.0.5" } }, + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true + }, "@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -7514,6 +8394,28 @@ } } }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -7643,10 +8545,10 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, - "@tootallnate/quickjs-emscripten": { - "version": "0.23.0", - "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", - "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" + "@tootallnate/once": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", + "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==" }, "@tsconfig/node10": { "version": "1.0.8", @@ -7672,6 +8574,21 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, + "@types/chai": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", + "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", + "dev": true + }, + "@types/cucumber": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/cucumber/-/cucumber-7.0.0.tgz", + "integrity": "sha512-cr5NN8/jmbw3vDKTQfGW0cSzDtkvxixu9bUD6po9U6OEF04XLuukTDldFG34ccDscLkA8bYnZ7VjxP79cIC7tg==", + "dev": true, + "requires": { + "@cucumber/cucumber": "*" + } + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -7745,6 +8662,35 @@ "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", "dev": true }, + "@types/node-fetch": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", + "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", + "dev": true, + "requires": { + "@types/node": "*", + "form-data": "^3.0.0" + }, + "dependencies": { + "form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, + "@types/pubnub": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", + "integrity": "sha512-Ui58Xsn8/4Ty1hFW0t91ED6FKezzipjO+GEJviOdJdqp817+I5/WMfo5zBsDfjbZQWMqcdrktMauKpUqiIF1wA==", + "dev": true + }, "@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -7761,10 +8707,11 @@ "dev": true }, "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", + "dev": true, + "peer": true }, "@types/yargs": { "version": "16.0.4", @@ -7911,10 +8858,9 @@ } }, "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", - "dev": true + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", + "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==" }, "acorn-jsx": { "version": "5.3.2", @@ -7926,8 +8872,7 @@ "acorn-walk": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", - "dev": true + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" }, "after": { "version": "0.8.2", @@ -7936,21 +8881,11 @@ "dev": true }, "agent-base": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", - "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "requires": { - "debug": "^4.3.4" - }, - "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - } + "debug": "4" } }, "agentkeepalive": { @@ -8049,11 +8984,6 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, - "asap": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" - }, "asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -8140,11 +9070,6 @@ "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", "dev": true }, - "basic-ftp": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.3.tgz", - "integrity": "sha512-QHX8HLlncOLpy54mh+k/sWIFd0ThmRqwe9ZjELybGZK+tZ8rUb9VO0saKJUROTbE+KhzDUT7xziGpGrW8Kmd+g==" - }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -8154,6 +9079,13 @@ "tweetnacl": "^0.14.3" } }, + "becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==", + "dev": true, + "peer": true + }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -8262,13 +9194,13 @@ "bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "dev": true + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -8380,18 +9312,19 @@ } }, "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", + "dev": true, + "peer": true }, "cli-table3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", - "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", + "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", "dev": true, "requires": { - "colors": "1.4.0", + "@colors/colors": "1.5.0", "string-width": "^4.2.0" } }, @@ -8524,15 +9457,21 @@ "dev": true }, "cookiejar": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", - "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" + }, + "core-js-pure": { + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", + "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", + "dev": true, + "peer": true }, "core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "create-require": { "version": "1.1.1", @@ -8562,6 +9501,158 @@ } } }, + "cucumber": { + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.7.tgz", + "integrity": "sha512-pN3AgWxHx8rOi+wOlqjASNETOjf3TgeyqhMNLQam7nSTXgQzju1oAmXkleRQRcXvpVvejcDHiZBLFSfBkqbYpA==", + "dev": true, + "peer": true, + "requires": { + "assertion-error-formatter": "^3.0.0", + "bluebird": "^3.4.1", + "cli-table3": "^0.5.1", + "colors": "^1.1.2", + "commander": "^3.0.1", + "cucumber-expressions": "^8.1.0", + "cucumber-tag-expressions": "^2.0.2", + "duration": "^0.2.1", + "escape-string-regexp": "^2.0.0", + "figures": "^3.0.0", + "gherkin": "5.0.0", + "glob": "^7.1.3", + "indent-string": "^4.0.0", + "is-generator": "^1.0.2", + "is-stream": "^2.0.0", + "knuth-shuffle-seeded": "^1.0.6", + "lodash": "^4.17.14", + "mz": "^2.4.0", + "progress": "^2.0.0", + "resolve": "^1.3.3", + "serialize-error": "^4.1.0", + "stack-chain": "^2.0.0", + "stacktrace-js": "^2.0.0", + "string-argv": "^0.3.0", + "title-case": "^2.1.1", + "util-arity": "^1.0.2", + "verror": "^1.9.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "peer": true + }, + "cli-table3": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", + "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", + "dev": true, + "peer": true, + "requires": { + "colors": "^1.1.2", + "object-assign": "^4.1.0", + "string-width": "^2.1.1" + } + }, + "commander": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", + "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", + "dev": true, + "peer": true + }, + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "peer": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true, + "peer": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "peer": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "peer": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "cucumber-expressions": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/cucumber-expressions/-/cucumber-expressions-8.3.0.tgz", + "integrity": "sha512-cP2ya0EiorwXBC7Ll7Cj7NELYbasNv9Ty42L4u7sso9KruWemWG1ZiTq4PMqir3SNDSrbykoqI5wZgMbLEDjLQ==", + "dev": true, + "peer": true, + "requires": { + "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0", + "xregexp": "^4.2.4" + }, + "dependencies": { + "xregexp": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.4.1.tgz", + "integrity": "sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==", + "dev": true, + "peer": true, + "requires": { + "@babel/runtime-corejs3": "^7.12.1" + } + } + } + }, + "cucumber-pretty": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cucumber-pretty/-/cucumber-pretty-6.0.1.tgz", + "integrity": "sha512-9uOIZ8x3lgCPROqYc7kqe2e7UrH5TZPZCdj5fVPze1XViG9yv8/8MnFsAnVINDYWVhiql8DJHb3UrZfIPHYH/A==", + "dev": true, + "requires": { + "cli-table3": "^0.6.0", + "colors": "^1.4.0", + "figures": "^3.2.0" + } + }, + "cucumber-tag-expressions": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/cucumber-tag-expressions/-/cucumber-tag-expressions-2.0.3.tgz", + "integrity": "sha512-+x5j1IfZrBtbvYHuoUX0rl4nUGxaey6Do9sM0CABmZfDCcWXuuRm1fQeCaklIYQgOFHQ6xOHvDSdkMHHpni6tQ==", + "dev": true, + "peer": true + }, + "cucumber-tsflow": { + "version": "4.0.0-rc.11", + "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-rc.11.tgz", + "integrity": "sha512-VK/RhJOOxS4KAH6UIkfLsDE2+H7OtP/+cwzx139gldqHP08hoYk/fMwOoXlGWXOOX2O3amJ6RTS0YMF2xCA8Bw==", + "dev": true, + "requires": { + "callsites": "^3.1.0", + "log4js": "^6.3.0", + "source-map-support": "^0.5.19", + "underscore": "^1.8.3" + } + }, "custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", @@ -8588,9 +9679,9 @@ } }, "data-uri-to-buffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-5.0.1.tgz", - "integrity": "sha512-a9l6T1qqDogvvnw0nKlfZzqsyikEBZBClF39V3TFoKhDtGBqHu2HkuomJc02j5zft8zrUaXEuoicLeW54RkzPg==" + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", + "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==" }, "date-format": { "version": "4.0.3", @@ -8638,8 +9729,7 @@ "deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" }, "deepmerge": { "version": "4.2.2", @@ -8657,13 +9747,14 @@ } }, "degenerator": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", - "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.2.tgz", + "integrity": "sha512-c0mef3SNQo56t6urUU6tdQAs+ThoD0o9B9MJ8HEt7NQcGEILCRFqQb7ZbP9JAv+QF1Ky5plydhMR/IrqWDm+TQ==", "requires": { - "ast-types": "^0.13.4", - "escodegen": "^2.1.0", - "esprima": "^4.0.1" + "ast-types": "^0.13.2", + "escodegen": "^1.8.1", + "esprima": "^4.0.0", + "vm2": "^3.9.8" } }, "delayed-stream": { @@ -8674,17 +9765,7 @@ "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true - }, - "dezalgo": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", - "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", - "requires": { - "asap": "^2.0.0", - "wrappy": "1" - } + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" }, "di": { "version": "0.0.1", @@ -8853,12 +9934,12 @@ "dev": true }, "error-stack-parser": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.0.7.tgz", - "integrity": "sha512-chLOW0ZGRf4s8raLrDxa5sdkvPec5YdvwbFnqJme4rk0rFajP8mPtrDL1+I+CwrQDCjswDA5sREX7jYQDQs9vA==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", + "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", "dev": true, "requires": { - "stackframe": "^1.1.1" + "stackframe": "^1.3.4" } }, "es5-ext": { @@ -8924,24 +10005,37 @@ "dev": true }, "escodegen": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", - "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", "requires": { "esprima": "^4.0.1", - "estraverse": "^5.2.0", + "estraverse": "^4.2.0", "esutils": "^2.0.2", + "optionator": "^0.8.1", "source-map": "~0.6.1" + }, + "dependencies": { + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + } } }, "eslint": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", - "integrity": "sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q==", - "dev": true, - "requires": { - "@eslint/eslintrc": "^1.1.0", - "@humanwhocodes/config-array": "^0.9.2", + "version": "8.37.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", + "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.4.0", + "@eslint/eslintrc": "^2.0.2", + "@eslint/js": "8.37.0", + "@humanwhocodes/config-array": "^0.11.8", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -8949,32 +10043,32 @@ "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", - "esquery": "^1.4.0", + "eslint-visitor-keys": "^3.4.0", + "espree": "^9.5.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", - "regexpp": "^3.2.0", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "dependencies": { "ansi-styles": { @@ -9032,15 +10126,6 @@ "is-glob": "^4.0.3" } }, - "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -9153,20 +10238,20 @@ } }, "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", + "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", "dev": true }, "espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", + "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", "dev": true, "requires": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^3.3.0" + "acorn": "^8.8.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.0" } }, "esprima": { @@ -9175,9 +10260,9 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, "esquery": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", - "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -9195,7 +10280,8 @@ "estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==" + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true }, "estree-walker": { "version": "2.0.2", @@ -9318,8 +10404,7 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, "fast-safe-stringify": { "version": "2.1.1", @@ -9362,6 +10447,11 @@ "flat-cache": "^3.0.4" } }, + "file-uri-to-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", + "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==" + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -9403,6 +10493,16 @@ } } }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, "flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -9449,25 +10549,9 @@ } }, "formidable": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", - "integrity": "sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==", - "requires": { - "dezalgo": "^1.0.4", - "hexoid": "^1.0.0", - "once": "^1.4.0", - "qs": "^6.11.0" - }, - "dependencies": { - "qs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", - "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", - "requires": { - "side-channel": "^1.0.4" - } - } - } + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", + "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==" }, "fs-extra": { "version": "1.0.0", @@ -9493,10 +10577,43 @@ "dev": true, "optional": true }, + "ftp": { + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", + "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", + "requires": { + "readable-stream": "1.1.x", + "xregexp": "2.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + } + } + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "functional-red-black-tree": { "version": "1.0.1", @@ -9520,6 +10637,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -9527,24 +10645,18 @@ } }, "get-uri": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.1.tgz", - "integrity": "sha512-7ZqONUVqaabogsYNWlYj0t3YZaL6dhuEueZXGF+/YVmf6dHmaFg8/6psJKqhx9QykIDKzpGcy2cn4oV4YC7V/Q==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", + "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", "requires": { - "basic-ftp": "^5.0.2", - "data-uri-to-buffer": "^5.0.1", - "debug": "^4.3.4", - "fs-extra": "^8.1.0" + "@tootallnate/once": "1", + "data-uri-to-buffer": "3", + "debug": "4", + "file-uri-to-path": "2", + "fs-extra": "^8.1.0", + "ftp": "^0.3.10" }, "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -9558,7 +10670,7 @@ "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "requires": { "graceful-fs": "^4.1.6" } @@ -9574,6 +10686,13 @@ "assert-plus": "^1.0.0" } }, + "gherkin": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-5.0.0.tgz", + "integrity": "sha512-Y+93z2Nh+TNIKuKEf+6M0FQrX/z0Yv9C2LFfc5NlcGJWRrrTeI/jOg2374y1FOw6ZYQ3RgJBezRkli7CLDubDA==", + "dev": true, + "peer": true + }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -9597,6 +10716,15 @@ "is-glob": "^4.0.1" } }, + "globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, "globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -9616,6 +10744,12 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" }, + "grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -9642,6 +10776,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -9678,7 +10813,8 @@ "has-symbols": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", - "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==" + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true }, "has-tostringtag": { "version": "1.0.0", @@ -9713,16 +10849,10 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, - "hexoid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", - "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==" - }, "http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "dev": true, "requires": { "depd": "~1.1.2", "inherits": "2.0.4", @@ -9743,22 +10873,13 @@ } }, "http-proxy-agent": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", - "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", + "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", "requires": { - "agent-base": "^7.1.0", - "debug": "^4.3.4" - }, - "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - } + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4" } }, "http-signature": { @@ -9773,11 +10894,11 @@ } }, "https-proxy-agent": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.1.tgz", - "integrity": "sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", + "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", "requires": { - "agent-base": "^7.0.2", + "agent-base": "6", "debug": "4" } }, @@ -9793,7 +10914,6 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } @@ -9850,13 +10970,12 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ip": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", - "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" }, "is-arguments": { "version": "1.1.1", @@ -9934,6 +11053,12 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, "is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -10229,6 +11354,12 @@ } } }, + "js-sdsl": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", + "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", + "dev": true + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -10436,11 +11567,29 @@ "seed-random": "~2.2.0" } }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, "lil-uuid": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", "integrity": "sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY=" }, + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "requires": { + "p-locate": "^5.0.0" + } + }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", @@ -10543,9 +11692,12 @@ } }, "lru-cache": { - "version": "7.18.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", - "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==" + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "requires": { + "yallist": "^3.0.2" + } }, "magic-string": { "version": "0.25.7", @@ -10722,16 +11874,6 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -10747,15 +11889,6 @@ "argparse": "^2.0.1" } }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -10771,30 +11904,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, "serialize-javascript": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", @@ -10970,9 +12079,9 @@ } }, "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", "dev": true, "requires": { "whatwg-url": "^5.0.0" @@ -10996,11 +12105,6 @@ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, - "object-inspect": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==" - }, "object-is": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", @@ -11030,43 +12134,66 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, "pac-proxy-agent": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.0.tgz", - "integrity": "sha512-t4tRAMx0uphnZrio0S0Jw9zg3oDbz1zVhQ/Vy18FjLfP1XOLNUEjaVxYCYRI6NS+BsMBXKIzV6cTLOkO9AtywA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", + "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", "requires": { - "@tootallnate/quickjs-emscripten": "^0.23.0", - "agent-base": "^7.0.2", - "debug": "^4.3.4", - "get-uri": "^6.0.1", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.0", - "pac-resolver": "^7.0.0", - "socks-proxy-agent": "^8.0.1" - }, - "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - } + "@tootallnate/once": "1", + "agent-base": "6", + "debug": "4", + "get-uri": "3", + "http-proxy-agent": "^4.0.1", + "https-proxy-agent": "5", + "pac-resolver": "^5.0.0", + "raw-body": "^2.2.0", + "socks-proxy-agent": "5" } }, "pac-resolver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", - "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.0.tgz", + "integrity": "sha512-H+/A6KitiHNNW+bxBKREk2MCGSxljfqRX76NjummWEYIat7ldVXRU3dhRIE3iXZ0nvGBk6smv3nntxKkzRL8NA==", "requires": { - "degenerator": "^5.0.0", - "ip": "^1.1.8", - "netmask": "^2.0.2" + "degenerator": "^3.0.1", + "ip": "^1.1.5", + "netmask": "^2.0.1" } }, "pad-right": { @@ -11105,6 +12232,12 @@ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -11210,6 +12343,11 @@ "pinkie": "^2.0.0" } }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, "prettier": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", @@ -11269,28 +12407,18 @@ "dev": true }, "proxy-agent": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.3.0.tgz", - "integrity": "sha512-0LdR757eTj/JfuU7TL2YCuAZnxWXu3tkJbg4Oq3geW/qFNT/32T0sp2HnZ9O0lMR4q3vwAt0+xCA8SR0WAD0og==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", + "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", "requires": { - "agent-base": "^7.0.2", - "debug": "^4.3.4", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.0", - "lru-cache": "^7.14.1", - "pac-proxy-agent": "^7.0.0", - "proxy-from-env": "^1.1.0", - "socks-proxy-agent": "^8.0.1" - }, - "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - } + "agent-base": "^6.0.0", + "debug": "4", + "http-proxy-agent": "^4.0.0", + "https-proxy-agent": "^5.0.0", + "lru-cache": "^5.1.1", + "pac-proxy-agent": "^5.0.0", + "proxy-from-env": "^1.0.0", + "socks-proxy-agent": "^5.0.0" } }, "proxy-from-env": { @@ -11319,8 +12447,7 @@ "qs": { "version": "6.9.7", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", - "dev": true + "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==" }, "queue-microtask": { "version": "1.2.3", @@ -11353,7 +12480,6 @@ "version": "2.4.3", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", - "dev": true, "requires": { "bytes": "3.1.2", "http-errors": "1.8.1", @@ -11391,6 +12517,13 @@ "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", "dev": true }, + "regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "dev": true, + "peer": true + }, "regexp-match-indices": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regexp-match-indices/-/regexp-match-indices-1.0.2.tgz", @@ -11592,14 +12725,12 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "seed-random": { "version": "2.2.0", @@ -11608,9 +12739,9 @@ "dev": true }, "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", "requires": { "lru-cache": "^6.0.0" }, @@ -11622,6 +12753,30 @@ "requires": { "yallist": "^4.0.0" } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, + "serialize-error": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", + "integrity": "sha512-5j9GgyGsP9vV9Uj1S0lDCvlsd+gc2LEPVK7HHHte7IyPwOD4lVQFeaX143gx3U5AnoCi+wbcb3mvaxVysjpxEw==", + "dev": true, + "peer": true, + "requires": { + "type-fest": "^0.3.0" + }, + "dependencies": { + "type-fest": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", + "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", + "dev": true, + "peer": true } } }, @@ -11643,8 +12798,7 @@ "setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "dev": true + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "shebang-command": { "version": "2.0.0", @@ -11661,16 +12815,6 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, - "side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", - "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "requires": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - } - }, "sinon": { "version": "7.5.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", @@ -11831,39 +12975,22 @@ } }, "socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", + "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", "requires": { - "ip": "^2.0.0", + "ip": "^1.1.5", "smart-buffer": "^4.2.0" - }, - "dependencies": { - "ip": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", - "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" - } } }, "socks-proxy-agent": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.1.tgz", - "integrity": "sha512-59EjPbbgg8U3x62hhKOFVAmySQUcfRQ4C7Q/D5sEHnZTQRrQlNKINks44DMR1gwXp0p4LaVIeccX2KHTTcHVqQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", + "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", "requires": { - "agent-base": "^7.0.1", - "debug": "^4.3.4", - "socks": "^2.7.1" - }, - "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - } + "agent-base": "^6.0.2", + "debug": "4", + "socks": "^2.3.3" } }, "source-map": { @@ -11873,9 +13000,9 @@ "devOptional": true }, "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -11944,9 +13071,9 @@ } }, "stackframe": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.2.1.tgz", - "integrity": "sha512-h88QkzREN/hy8eRdyNhhsO7RSJ5oyTqxxmmn0dzBIMUclZsjpfmrsg81vp8mjjAs2vAZ72nyWxRUwSwmh0e4xg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", + "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==", "dev": true }, "stacktrace-gps": { @@ -11981,8 +13108,7 @@ "statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" }, "streamroller": { "version": "3.0.2", @@ -12028,7 +13154,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, "requires": { "safe-buffer": "~5.1.0" } @@ -12081,50 +13206,54 @@ "dev": true }, "superagent": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.1.2.tgz", - "integrity": "sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-6.1.0.tgz", + "integrity": "sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==", "requires": { "component-emitter": "^1.3.0", - "cookiejar": "^2.1.4", - "debug": "^4.3.4", - "fast-safe-stringify": "^2.1.1", - "form-data": "^4.0.0", - "formidable": "^2.1.2", + "cookiejar": "^2.1.2", + "debug": "^4.1.1", + "fast-safe-stringify": "^2.0.7", + "form-data": "^3.0.0", + "formidable": "^1.2.2", "methods": "^1.1.2", - "mime": "2.6.0", - "qs": "^6.11.0", - "semver": "^7.3.8" + "mime": "^2.4.6", + "qs": "^6.9.4", + "readable-stream": "^3.6.0", + "semver": "^7.3.2" }, "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - }, "form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "mime-types": "^2.1.12" } }, - "qs": { - "version": "6.11.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", - "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "requires": { - "side-channel": "^1.0.4" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } } } }, + "superagent-proxy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/superagent-proxy/-/superagent-proxy-3.0.0.tgz", + "integrity": "sha512-wAlRInOeDFyd9pyonrkJspdRAxdLrcsZ6aSnS+8+nu4x1aXbz6FWSTT9M6Ibze+eG60szlL7JA8wEIV7bPWuyQ==", + "requires": { + "debug": "^4.3.2", + "proxy-agent": "^5.0.0" + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -12163,24 +13292,6 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", "dev": true - }, - "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } } } }, @@ -12214,6 +13325,36 @@ "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", "dev": true }, + "title-case": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", + "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", + "dev": true, + "peer": true, + "requires": { + "no-case": "^2.2.0", + "upper-case": "^1.0.3" + }, + "dependencies": { + "lower-case": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", + "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", + "dev": true, + "peer": true + }, + "no-case": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", + "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", + "dev": true, + "peer": true, + "requires": { + "lower-case": "^1.1.1" + } + } + } + }, "tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -12241,8 +13382,7 @@ "toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "dev": true + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" }, "tough-cookie": { "version": "2.5.0", @@ -12260,6 +13400,12 @@ "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", "dev": true }, + "ts-dedent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", + "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", + "dev": true + }, "ts-mocha": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-9.0.2.tgz", @@ -12301,12 +13447,12 @@ } }, "ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", "dev": true, "requires": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -12317,7 +13463,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" } }, @@ -12389,6 +13535,14 @@ "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", "dev": true }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -12418,9 +13572,9 @@ "dev": true }, "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true }, "ua-parser-js": { @@ -12443,8 +13597,14 @@ "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "upper-case": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", + "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", + "dev": true, + "peer": true }, "upper-case-first": { "version": "2.0.2", @@ -12473,8 +13633,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "utils-merge": { "version": "1.0.1", @@ -12483,21 +13642,16 @@ "dev": true }, "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - }, - "v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", - "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", - "dev": true + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true, + "peer": true }, "v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "verror": { @@ -12519,6 +13673,15 @@ } } }, + "vm2": { + "version": "3.9.8", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.8.tgz", + "integrity": "sha512-/1PYg/BwdKzMPo8maOZ0heT7DLI0DAFTm7YQaz/Lim9oIaFZsJs3EdtalvXuBfZwczNwsYhju75NW4d6E+4q+w==", + "requires": { + "acorn": "^8.7.0", + "acorn-walk": "^8.2.0" + } + }, "void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -12559,8 +13722,7 @@ "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" }, "workerpool": { "version": "6.2.0", @@ -12608,7 +13770,8 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "ws": { "version": "7.4.6", @@ -12623,6 +13786,11 @@ "integrity": "sha512-3XfeQE/wNkvrIktn2Kf0869fC0BN6UpydVasGIeSm2B1Llihf7/0UfZM+eCkOw3P7bP4+qPgqhm7ZoxuJtFU0Q==", "dev": true }, + "xregexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", + "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=" + }, "y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", @@ -12630,9 +13798,9 @@ "dev": true }, "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" }, "yargs": { "version": "15.4.1", @@ -12696,12 +13864,6 @@ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, "yargs-parser": { "version": "18.1.3", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", From 128c6784b09bc0a4669bb947c7d9b3af3860204c Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 9 Jan 2024 11:59:38 +0530 Subject: [PATCH 32/63] WIP take-1(non-status events): Listener compatibility with eventEngine --- src/core/components/eventEmitter.js | 222 ++++++++++++++++++++++++++++ src/core/pubnub-common.js | 10 +- 2 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 src/core/components/eventEmitter.js diff --git a/src/core/components/eventEmitter.js b/src/core/components/eventEmitter.js new file mode 100644 index 000000000..05a39972f --- /dev/null +++ b/src/core/components/eventEmitter.js @@ -0,0 +1,222 @@ +export default class EventEmitter { + modules; + listenerManager; + getFileUrl; + + _decoder; + constructor({ modules, listenerManager, getFileUrl }) { + this.modules = modules; + this.listenerManager = listenerManager; + this.getFileUrl = getFileUrl; + if (modules.cryptoModule) this._decoder = new TextDecoder(); + } + emitEvent(e) { + const { channel, publishMetaData } = e; + let { subscriptionMatch } = e; + if (channel === subscriptionMatch) { + subscriptionMatch = null; + } + + if (e.channel.endsWith('-pnpres')) { + const announce = {}; + announce.channel = null; + announce.subscription = null; + + if (channel) { + announce.channel = channel.substring(0, channel.lastIndexOf('-pnpres')); + } + + if (subscriptionMatch) { + announce.subscription = subscriptionMatch.substring(0, subscriptionMatch.lastIndexOf('-pnpres')); + } + + announce.action = e.payload.action; + announce.state = e.payload.data; + announce.timetoken = publishMetaData.publishTimetoken; + announce.occupancy = e.payload.occupancy; + announce.uuid = e.payload.uuid; + announce.timestamp = e.payload.timestamp; + + if (e.payload.join) { + announce.join = e.payload.join; + } + + if (e.payload.leave) { + announce.leave = e.payload.leave; + } + + if (e.payload.timeout) { + announce.timeout = e.payload.timeout; + } + + this.listenerManager.announcePresence(announce); + } else if (e.messageType === 1) { + const announce = {}; + announce.channel = null; + announce.subscription = null; + + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + + announce.message = e.payload; + + this.listenerManager.announceSignal(announce); + } else if (e.messageType === 2) { + const announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + announce.message = { + event: e.payload.event, + type: e.payload.type, + data: e.payload.data, + }; + this.listenerManager.announceObjects(announce); + if (e.payload.type === 'uuid') { + const eventData = this._renameChannelField(announce); + this.listenerManager.announceUser({ + ...eventData, + message: { + ...eventData.message, + event: this._renameEvent(eventData.message.event), + type: 'user', + }, + }); + } else if (message.payload.type === 'channel') { + const eventData = this._renameChannelField(announce); + this.listenerManager.announceSpace({ + ...eventData, + message: { + ...eventData.message, + event: this._renameEvent(eventData.message.event), + type: 'space', + }, + }); + } else if (message.payload.type === 'membership') { + const eventData = this._renameChannelField(announce); + const { uuid: user, channel: space, ...membershipData } = eventData.message.data; + membershipData.user = user; + membershipData.space = space; + this.listenerManager.announceMembership({ + ...eventData, + message: { + ...eventData.message, + event: this._renameEvent(eventData.message.event), + data: membershipData, + }, + }); + } + } else if (e.messageType === 3) { + const announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + announce.data = { + messageTimetoken: e.payload.data.messageTimetoken, + actionTimetoken: e.payload.data.actionTimetoken, + type: e.payload.data.type, + uuid: e.issuingClientId, + value: e.payload.data.value, + }; + announce.event = e.payload.event; + this.listenerManager.announceMessageAction(announce); + } else if (e.messageType === 4) { + const announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + + let msgPayload = e.payload; + + if (this.modules.cryptoModule) { + let decryptedPayload; + try { + const decryptedData = this.modules.cryptoModule.decrypt(e.payload); + decryptedPayload = + decryptedData instanceof ArrayBuffer ? JSON.parse(this._decoder.decode(decryptedData)) : decryptedData; + } catch (e) { + decryptedPayload = null; + announce.error = `Error while decrypting message content: ${e.message}`; + } + if (decryptedPayload !== null) { + msgPayload = decryptedPayload; + } + } + + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + + announce.message = msgPayload.message; + + announce.file = { + id: msgPayload.file.id, + name: msgPayload.file.name, + url: this.getFileUrl({ + id: msgPayload.file.id, + name: msgPayload.file.name, + channel, + }), + }; + + this.listenerManager.announceFile(announce); + } else { + const announce = {}; + announce.channel = null; + announce.subscription = null; + + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + + if (this.modules.cryptoModule) { + let decryptedPayload; + try { + const decryptedData = this.modules.cryptoModule.decrypt(e.payload); + decryptedPayload = + decryptedData instanceof ArrayBuffer ? JSON.parse(this._decoder.decode(decryptedData)) : decryptedData; + } catch (e) { + decryptedPayload = null; + announce.error = `Error while decrypting message content: ${e.message}`; + } + if (decryptedPayload != null) { + announce.message = decryptedPayload; + } else { + announce.message = e.payload; + } + } else { + announce.message = e.payload; + } + + this.listenerManager.announceMessage(announce); + } + } + + _renameEvent(e) { + return e === 'set' ? 'updated' : 'removed'; + } + + _renameChannelField(announce) { + const { channel, ...eventData } = announce; + eventData.spaceId = channel; + return eventData; + } +} diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 5456f65f4..ff07a683b 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -93,6 +93,7 @@ import uuidGenerator from './components/uuid'; import { EventEngine } from '../event-engine'; import { PresenceEventEngine } from '../event-engine/presence/presence'; import { RetryPolicy } from '../event-engine/core/retryPolicy'; +import EventEmitter from './components/eventEmitter'; export default class { _config; @@ -273,7 +274,7 @@ export default class { decrypt; - // + _eventEmitter; constructor(setup) { const { networking, cbor } = setup; @@ -341,6 +342,11 @@ export default class { this.receiveMessages = endpointCreator.bind(this, modules, receiveMessagesConfig); if (config.enableEventEngine === true) { + this._eventEmitter = new EventEmitter({ + modules: modules, + listenerManager: this._listenerManager, + getFileUrl: (params) => getFileUrlFunction(modules, params), + }); if (config.maintainPresenceState) { this.presenceState = {}; this.setState = (args) => { @@ -380,7 +386,7 @@ export default class { config: modules.config, emitEvents: (events) => { for (const event of events) { - listenerManager.announceMessage(event); + this._eventEmitter.emitEvent(event); } }, emitStatus: (status) => { From 200df8c354a3ecd5507589a01c15bdcf00ebff9a Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 9 Jan 2024 14:42:30 +0530 Subject: [PATCH 33/63] take-2: (presence) listener structs backward compatibility. --- src/event-engine/dispatcher.ts | 3 +- src/event-engine/presence/dispatcher.ts | 20 ++++++++++--- src/event-engine/presence/effects.ts | 4 ++- src/event-engine/presence/events.ts | 2 +- .../presence/states/heartbeat_reconnecting.ts | 19 ++++++++----- .../presence/states/heartbeating.ts | 28 +++++++++++-------- 6 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index 8b6417450..c948b3b29 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -35,7 +35,6 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler( async (payload, _, { emitEvents }) => { if (payload.length > 0) { emitEvents(payload); } diff --git a/src/event-engine/presence/dispatcher.ts b/src/event-engine/presence/dispatcher.ts index 910a092dc..eeae3520c 100644 --- a/src/event-engine/presence/dispatcher.ts +++ b/src/event-engine/presence/dispatcher.ts @@ -1,5 +1,6 @@ import { PubNubError } from '../../core/components/endpoint'; import { asyncHandler, Dispatcher, Engine } from '../core'; +import PNOperations from '../../core/constants/operations'; import * as effects from './effects'; import * as events from './events'; @@ -11,6 +12,8 @@ export type Dependencies = { retryDelay: (milliseconds: number) => Promise; config: any; presenceState: any; + + emitStatus: (status: any) => void; }; export class PresenceEventEngineDispatcher extends Dispatcher { @@ -26,8 +29,7 @@ export class PresenceEventEngineDispatcher extends Dispatcher { + if (config.announceFailedHeartbeats && payload?.status?.error === true) { + emitStatus(payload.status); + } else if (config.announceSuccessfulHeartbeats && payload.statusCode === 200) { + emitStatus({ ...payload, operation: PNOperations.PNHeartbeatOperation, error: false }); + } + }), + ); } } diff --git a/src/event-engine/presence/effects.ts b/src/event-engine/presence/effects.ts index efbd786f2..b5317818f 100644 --- a/src/event-engine/presence/effects.ts +++ b/src/event-engine/presence/effects.ts @@ -11,6 +11,8 @@ export const leave = createEffect('LEAVE', (channels: string[], groups: string[] groups, })); +export const emitStatus = createEffect('EMIT_STATUS', (status: any) => status); + export const wait = createManagedEffect('WAIT', () => ({})); export const delayedHeartbeat = createManagedEffect( @@ -18,4 +20,4 @@ export const delayedHeartbeat = createManagedEffect( (context: HeartbeatReconnectingStateContext) => context, ); -export type Effects = MapOf; +export type Effects = MapOf; diff --git a/src/event-engine/presence/events.ts b/src/event-engine/presence/events.ts index 4dc50e448..3e964c4af 100644 --- a/src/event-engine/presence/events.ts +++ b/src/event-engine/presence/events.ts @@ -16,7 +16,7 @@ export const left = createEvent('LEFT', (channels: string[], groups: string[]) = export const leftAll = createEvent('LEFT_ALL', () => ({})); -export const heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', () => ({})); +export const heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', (statusCode: number) => ({ statusCode})); export const heartbeatFailure = createEvent('HEARTBEAT_FAILURE', (error: PubNubError) => error); diff --git a/src/event-engine/presence/states/heartbeat_reconnecting.ts b/src/event-engine/presence/states/heartbeat_reconnecting.ts index 2d64afeb6..99ac2a1a7 100644 --- a/src/event-engine/presence/states/heartbeat_reconnecting.ts +++ b/src/event-engine/presence/states/heartbeat_reconnecting.ts @@ -10,7 +10,7 @@ import { left, leftAll, } from '../events'; -import { Effects, delayedHeartbeat, leave } from '../effects'; +import { Effects, delayedHeartbeat, emitStatus, leave } from '../effects'; import { HeartbeatingState } from './heartbeating'; import { HeartbeatStoppedState } from './heartbeat_stopped'; import { HeartbeatCooldownState } from './heartbeat_cooldown'; @@ -59,15 +59,20 @@ HearbeatReconnectingState.on(disconnect.type, (context, _) => { ); }); -HearbeatReconnectingState.on(heartbeatSuccess.type, (context, _) => { - return HeartbeatCooldownState.with({ - channels: context.channels, - groups: context.groups, - }); +HearbeatReconnectingState.on(heartbeatSuccess.type, (context, event) => { + return HeartbeatCooldownState.with( + { + channels: context.channels, + groups: context.groups, + }, + [emitStatus(event.payload)], + ); }); HearbeatReconnectingState.on(heartbeatFailure.type, (context, event) => - HearbeatReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), + HearbeatReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }, [ + emitStatus(event.payload), + ]), ); HearbeatReconnectingState.on(heartbeatGiveup.type, (context, event) => { diff --git a/src/event-engine/presence/states/heartbeating.ts b/src/event-engine/presence/states/heartbeating.ts index cab28ed57..04ebea99f 100644 --- a/src/event-engine/presence/states/heartbeating.ts +++ b/src/event-engine/presence/states/heartbeating.ts @@ -1,6 +1,6 @@ import { State } from '../../core/state'; import { Events, disconnect, heartbeatFailure, heartbeatSuccess, joined, left, leftAll } from '../events'; -import { Effects, heartbeat, leave } from '../effects'; +import { Effects, emitStatus, heartbeat, leave } from '../effects'; import { HeartbeatCooldownState } from './heartbeat_cooldown'; import { HearbeatReconnectingState } from './heartbeat_reconnecting'; import { HeartbeatStoppedState } from './heartbeat_stopped'; @@ -15,11 +15,14 @@ export const HeartbeatingState = new State heartbeat(context.channels, context.groups)); -HeartbeatingState.on(heartbeatSuccess.type, (context, _) => { - return HeartbeatCooldownState.with({ - channels: context.channels, - groups: context.groups, - }); +HeartbeatingState.on(heartbeatSuccess.type, (context, event) => { + return HeartbeatCooldownState.with( + { + channels: context.channels, + groups: context.groups, + }, + [emitStatus(event.payload)], + ); }); HeartbeatingState.on(joined.type, (context, event) => @@ -40,11 +43,14 @@ HeartbeatingState.on(left.type, (context, event) => { }); HeartbeatingState.on(heartbeatFailure.type, (context, event) => { - return HearbeatReconnectingState.with({ - ...context, - attempts: 0, - reason: event.payload, - }); + return HearbeatReconnectingState.with( + { + ...context, + attempts: 0, + reason: event.payload, + }, + [emitStatus(event.payload)], + ); }); HeartbeatingState.on(disconnect.type, (context) => From 1b4d38ed9745f0eead0933ec3dfd72334c7bd716 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 9 Jan 2024 14:43:07 +0530 Subject: [PATCH 34/63] lib and dist --- dist/web/pubnub.js | 273 ++++++++++++++++-- dist/web/pubnub.min.js | 4 +- lib/core/components/eventEmitter.js | 214 ++++++++++++++ lib/core/pubnub-common.js | 12 +- lib/event-engine/dispatcher.js | 2 + lib/event-engine/events.js | 2 +- lib/event-engine/presence/dispatcher.js | 38 ++- lib/event-engine/presence/effects.js | 3 +- lib/event-engine/presence/events.js | 2 +- .../presence/states/heartbeating.js | 6 +- lib/node/index.js | 4 +- src/core/pubnub-common.js | 3 + 12 files changed, 523 insertions(+), 40 deletions(-) create mode 100644 lib/core/components/eventEmitter.js diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index c26d9de00..ebeef507c 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -7147,7 +7147,7 @@ }); }); var receiveEvents = createManagedEffect('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); var emitEvents = createEffect('EMIT_MESSAGES', function (events) { return events; }); - var emitStatus = createEffect('EMIT_STATUS', function (status) { return status; }); + var emitStatus$1 = createEffect('EMIT_STATUS', function (status) { return status; }); var reconnect$2 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); @@ -7183,7 +7183,7 @@ var reconnectingFailure = createEvent('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); var reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); var reconnectingRetry = createEvent('RECONNECT', function () { return ({}); }); - var unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', function () { }); + var unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', function () { return ({}); }); var EventEngineDispatcher = /** @class */ (function (_super) { __extends(EventEngineDispatcher, _super); @@ -7209,9 +7209,11 @@ })]; case 2: result = _b.sent(); + console.log("handshake response = ".concat(JSON.stringify(result))); return [2 /*return*/, engine.transition(handshakingSuccess(result))]; case 3: e_1 = _b.sent(); + console.log('at effect, received error = ', e_1, '\n', "".concat(e_1)); if (e_1 instanceof Error && e_1.message === 'Aborted') { return [2 /*return*/]; } @@ -7272,7 +7274,7 @@ }); }); })); - _this.on(emitStatus.type, asyncHandler(function (payload, _, _a) { + _this.on(emitStatus$1.type, asyncHandler(function (payload, _, _a) { var emitStatus = _a.emitStatus; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { @@ -7462,14 +7464,14 @@ channels: context.channels, cursor: context.cursor, reason: context.reason, - }, [emitStatus({ category: categories.PNDisconnectedUnexpectedlyCategory })]); + }, [emitStatus$1({ category: categories.PNDisconnectedUnexpectedlyCategory })]); }); ReceiveReconnectingState.on(disconnect$1.type, function (context) { return ReceiveStoppedState.with({ channels: context.channels, groups: context.groups, cursor: context.cursor, - }, [emitStatus({ category: categories.PNDisconnectedCategory })]); + }, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); }); ReceiveReconnectingState.on(restore.type, function (context, event) { var _a, _b; @@ -7490,7 +7492,7 @@ }); }); ReceiveReconnectingState.on(unsubscribeAll.type, function (_) { - return UnsubscribedState.with(undefined, [emitStatus({ category: categories.PNDisconnectedCategory })]); + return UnsubscribedState.with(undefined, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); }); var ReceivingState = new State('RECEIVING'); @@ -7519,10 +7521,10 @@ channels: context.channels, groups: context.groups, cursor: context.cursor, - }, [emitStatus({ category: categories.PNDisconnectedCategory })]); + }, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); }); ReceivingState.on(unsubscribeAll.type, function (_) { - return UnsubscribedState.with(undefined, [emitStatus({ category: categories.PNDisconnectedCategory })]); + return UnsubscribedState.with(undefined, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); }); var HandshakeReconnectingState = new State('HANDSHAKE_RECONNECTING'); @@ -7534,7 +7536,7 @@ channels: context.channels, groups: context.groups, cursor: cursor, - }, [emitStatus({ category: categories.PNConnectedCategory })]); + }, [emitStatus$1({ category: categories.PNConnectedCategory })]); }); HandshakeReconnectingState.on(handshakingReconnectingFailure.type, function (context, event) { return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); @@ -7544,13 +7546,13 @@ groups: context.groups, channels: context.channels, reason: context.reason, - }, [emitStatus({ category: categories.PNConnectionErrorCategory })]); + }, [emitStatus$1({ category: categories.PNConnectionErrorCategory })]); }); HandshakeReconnectingState.on(disconnect$1.type, function (context) { return HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - }, [emitStatus({ category: categories.PNDisconnectedCategory })]); + }, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); }); HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); @@ -7559,7 +7561,7 @@ return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); HandshakeReconnectingState.on(unsubscribeAll.type, function (_) { - return UnsubscribedState.with(undefined, [emitStatus({ category: categories.PNDisconnectedCategory })]); + return UnsubscribedState.with(undefined, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); }); var HandshakingState = new State('HANDSHAKING'); @@ -7579,7 +7581,7 @@ timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, region: event.payload.region, }, - }, [emitStatus({ category: categories.PNConnectedCategory })]); + }, [emitStatus$1({ category: categories.PNConnectedCategory })]); }); HandshakingState.on(handshakingFailure.type, function (context, event) { return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); @@ -7719,7 +7721,7 @@ groups: groups, }); }); var leftAll = createEvent('LEFT_ALL', function () { return ({}); }); - var heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', function () { return ({}); }); + var heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', function (statusCode) { return ({ statusCode: statusCode }); }); var heartbeatFailure = createEvent('HEARTBEAT_FAILURE', function (error) { return error; }); var heartbeatGiveup = createEvent('HEARTBEAT_GIVEUP', function () { return ({}); }); var timesUp = createEvent('TIMES_UP', function () { return ({}); }); @@ -7732,6 +7734,7 @@ channels: channels, groups: groups, }); }); + var emitStatus = createEffect('EMIT_STATUS', function (status) { return status; }); var wait = createManagedEffect('WAIT', function () { return ({}); }); var delayedHeartbeat = createManagedEffect('DELAYED_HEARTBEAT', function (context) { return context; }); @@ -7742,7 +7745,7 @@ _this.on(heartbeat.type, asyncHandler(function (payload, _, _a) { var heartbeat = _a.heartbeat, presenceState = _a.presenceState; return __awaiter(_this, void 0, void 0, function () { - var e_1; + var result, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -7753,8 +7756,9 @@ state: presenceState, })]; case 1: - _b.sent(); - engine.transition(heartbeatSuccess()); + result = _b.sent(); + console.log('heartbeat Success: result = ', result, '\n\n', JSON.stringify(result)); + engine.transition(heartbeatSuccess(200)); return [3 /*break*/, 3]; case 2: e_1 = _b.sent(); @@ -7831,8 +7835,7 @@ })]; case 3: _b.sent(); - console.log("after hb call"); - return [2 /*return*/, engine.transition(heartbeatSuccess())]; + return [2 /*return*/, engine.transition(heartbeatSuccess(200))]; case 4: e_3 = _b.sent(); if (e_3 instanceof Error && e_3.message === 'Aborted') { @@ -7849,6 +7852,23 @@ }); }); })); + _this.on(emitStatus.type, asyncHandler(function (payload, _, _a) { + var emitStatus = _a.emitStatus, config = _a.config; + return __awaiter(_this, void 0, void 0, function () { + var _b; + return __generator(this, function (_c) { + if (config.announceFailedHeartbeats && ((_b = payload === null || payload === void 0 ? void 0 : payload.status) === null || _b === void 0 ? void 0 : _b.error) === true) { + console.log('failed => payload.status :', payload.status); + emitStatus(payload.status); + } + else if (config.announceSuccessfulHeartbeats && payload.statusCode === 200) { + console.log('need to announce... received event.payload = ', payload); + emitStatus(__assign(__assign({}, payload), { operation: OPERATIONS.PNHeartbeatOperation, error: false })); + } + return [2 /*return*/]; + }); + }); + })); return _this; } return PresenceEventEngineDispatcher; @@ -7985,11 +8005,11 @@ var HeartbeatingState = new State('HEARTBEATING'); HeartbeatingState.onEnter(function (context) { return heartbeat(context.channels, context.groups); }); - HeartbeatingState.on(heartbeatSuccess.type, function (context, _) { + HeartbeatingState.on(heartbeatSuccess.type, function (context, event) { return HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups, - }); + }, [emitStatus(event.payload)]); }); HeartbeatingState.on(joined.type, function (context, event) { return HeartbeatingState.with({ @@ -8004,7 +8024,7 @@ }, [leave(event.payload.channels, event.payload.groups)]); }); HeartbeatingState.on(heartbeatFailure.type, function (context, event) { - return HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); + return HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload }), [emitStatus(event.payload)]); }); HeartbeatingState.on(disconnect.type, function (context) { return HeartbeatStoppedState.with({ @@ -8117,8 +8137,197 @@ return RetryPolicy; }()); + var EventEmitter = /** @class */ (function () { + function EventEmitter(_a) { + var modules = _a.modules, listenerManager = _a.listenerManager, getFileUrl = _a.getFileUrl; + this.modules = modules; + this.listenerManager = listenerManager; + this.getFileUrl = getFileUrl; + if (modules.cryptoModule) + this._decoder = new TextDecoder(); + } + EventEmitter.prototype.emitEvent = function (e) { + var channel = e.channel, publishMetaData = e.publishMetaData; + var subscriptionMatch = e.subscriptionMatch; + if (channel === subscriptionMatch) { + subscriptionMatch = null; + } + if (e.channel.endsWith('-pnpres')) { + var announce = {}; + announce.channel = null; + announce.subscription = null; + if (channel) { + announce.channel = channel.substring(0, channel.lastIndexOf('-pnpres')); + } + if (subscriptionMatch) { + announce.subscription = subscriptionMatch.substring(0, subscriptionMatch.lastIndexOf('-pnpres')); + } + announce.action = e.payload.action; + announce.state = e.payload.data; + announce.timetoken = publishMetaData.publishTimetoken; + announce.occupancy = e.payload.occupancy; + announce.uuid = e.payload.uuid; + announce.timestamp = e.payload.timestamp; + if (e.payload.join) { + announce.join = e.payload.join; + } + if (e.payload.leave) { + announce.leave = e.payload.leave; + } + if (e.payload.timeout) { + announce.timeout = e.payload.timeout; + } + this.listenerManager.announcePresence(announce); + } + else if (e.messageType === 1) { + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + announce.message = e.payload; + this.listenerManager.announceSignal(announce); + } + else if (e.messageType === 2) { + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + announce.message = { + event: e.payload.event, + type: e.payload.type, + data: e.payload.data, + }; + this.listenerManager.announceObjects(announce); + if (e.payload.type === 'uuid') { + var eventData = this._renameChannelField(announce); + this.listenerManager.announceUser(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), type: 'user' }) })); + } + else if (message.payload.type === 'channel') { + var eventData = this._renameChannelField(announce); + this.listenerManager.announceSpace(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), type: 'space' }) })); + } + else if (message.payload.type === 'membership') { + var eventData = this._renameChannelField(announce); + var _a = eventData.message.data, user = _a.uuid, space = _a.channel, membershipData = __rest(_a, ["uuid", "channel"]); + membershipData.user = user; + membershipData.space = space; + this.listenerManager.announceMembership(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), data: membershipData }) })); + } + } + else if (e.messageType === 3) { + var announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + announce.data = { + messageTimetoken: e.payload.data.messageTimetoken, + actionTimetoken: e.payload.data.actionTimetoken, + type: e.payload.data.type, + uuid: e.issuingClientId, + value: e.payload.data.value, + }; + announce.event = e.payload.event; + this.listenerManager.announceMessageAction(announce); + } + else if (e.messageType === 4) { + var announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + var msgPayload = e.payload; + if (this.modules.cryptoModule) { + var decryptedPayload = void 0; + try { + var decryptedData = this.modules.cryptoModule.decrypt(e.payload); + decryptedPayload = + decryptedData instanceof ArrayBuffer ? JSON.parse(this._decoder.decode(decryptedData)) : decryptedData; + } + catch (e) { + decryptedPayload = null; + announce.error = "Error while decrypting message content: ".concat(e.message); + } + if (decryptedPayload !== null) { + msgPayload = decryptedPayload; + } + } + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + announce.message = msgPayload.message; + announce.file = { + id: msgPayload.file.id, + name: msgPayload.file.name, + url: this.getFileUrl({ + id: msgPayload.file.id, + name: msgPayload.file.name, + channel: channel, + }), + }; + this.listenerManager.announceFile(announce); + } + else { + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + if (this.modules.cryptoModule) { + var decryptedPayload = void 0; + try { + var decryptedData = this.modules.cryptoModule.decrypt(e.payload); + decryptedPayload = + decryptedData instanceof ArrayBuffer ? JSON.parse(this._decoder.decode(decryptedData)) : decryptedData; + } + catch (e) { + decryptedPayload = null; + announce.error = "Error while decrypting message content: ".concat(e.message); + } + if (decryptedPayload != null) { + announce.message = decryptedPayload; + } + else { + announce.message = e.payload; + } + } + else { + announce.message = e.payload; + } + this.listenerManager.announceMessage(announce); + } + }; + EventEmitter.prototype.emitStatus = function (s) { + }; + EventEmitter.prototype._renameEvent = function (e) { + return e === 'set' ? 'updated' : 'removed'; + }; + EventEmitter.prototype._renameChannelField = function (announce) { + var channel = announce.channel, eventData = __rest(announce, ["channel"]); + eventData.spaceId = channel; + return eventData; + }; + return EventEmitter; + }()); + var default_1$3 = /** @class */ (function () { - // function default_1(setup) { var _this = this; var networking = setup.networking, cbor = setup.cbor; @@ -8173,6 +8382,11 @@ this.handshake = endpointCreator.bind(this, modules, endpoint$1); this.receiveMessages = endpointCreator.bind(this, modules, endpoint); if (config.enableEventEngine === true) { + this._eventEmitter = new EventEmitter({ + modules: modules, + listenerManager: this._listenerManager, + getFileUrl: function (params) { return getFileUrlFunction(modules, params); }, + }); if (config.maintainPresenceState) { this.presenceState = {}; this.setState = function (args) { @@ -8196,6 +8410,9 @@ retryDelay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, config: modules.config, presenceState: this.presenceState, + emitStatus: function (status) { + listenerManager.announceStatus(status); + }, }); this.presenceEventEngine = presenceEventEngine; this.join = this.presenceEventEngine.join.bind(presenceEventEngine); @@ -8216,7 +8433,7 @@ try { for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { var event_1 = events_1_1.value; - listenerManager.announceMessage(event_1); + _this._eventEmitter.emitEvent(event_1); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } @@ -9927,6 +10144,14 @@ if (isString(obj)) { return markBoxed(inspect(String(obj))); } + // note: in IE 8, sometimes `global !== window` but both are the prototypes of each other + /* eslint-env browser */ + if (typeof window !== 'undefined' && obj === window) { + return '{ [object Window] }'; + } + if (obj === commonjsGlobal) { + return '{ [object globalThis] }'; + } if (!isDate(obj) && !isRegExp$1(obj)) { var ys = arrObjKeys(obj, inspect); var isPlainObject = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object; diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 26d385d32..f8de18c4d 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return f(3,o.length),p(o);default:var h;if(Array.isArray(t))for(f(4,h=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var b=function e(){var o,f,b=l(),v=b>>5,m=31&b;if(7===v)switch(m){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((f=d(m))<0&&(v<2||6=0;)S+=f,_.push(c(f));var O=new Uint8Array(S),P=0;for(o=0;o<_.length;++o)O.set(_[o],P),P+=_[o].length;return O}return c(f);case 3:var w=[];if(f<0)for(;(f=y(v))>=0;)g(w,f);else g(w,f);return String.fromCharCode.apply(null,w);case 4:var E;if(f<0)for(E=[];!h();)E.push(e());else for(E=new Array(f),o=0;o0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return f(3,o.length),p(o);default:var h;if(Array.isArray(t))for(f(4,h=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,f,m=l(),b=m>>5,v=31&m;if(7===b)switch(v){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((f=d(v))<0&&(b<2||6=0;)S+=f,_.push(c(f));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(f);case 3:var P=[];if(f<0)for(;(f=y(b))>=0;)g(P,f);else g(P,f);return String.fromCharCode.apply(null,P);case 4:var E;if(f<0)for(E=[];!h();)E.push(e());else for(E=new Array(f),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function b(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,h=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=f,64!=l&&(o[s+1]=h),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var m,_,S,O,P,w=w||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),f=2;f<=p;f++)if(!(l%f)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var h=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],f=0;64>f;f++){if(16>f)h[f]=0|e[t+f];else{var d=h[f-15],y=h[f-2];h[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+h[f-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+h[f-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+h[f],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(m=w).enc.Utf8,m.algo.HMAC=m.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return O.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=w,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],f=e[i+4],h=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],b=e[i+9],v=e[i+10],m=e[i+11],_=e[i+12],S=e[i+13],O=e[i+14],P=e[i+15],w=t(w=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,w,A,T,s,12,c[1]),T=t(T,E,w,A,l,17,c[2]),A=t(A,T,E,w,p,22,c[3]);w=t(w,A,T,E,f,7,c[4]),E=t(E,w,A,T,h,12,c[5]),T=t(T,E,w,A,d,17,c[6]),A=t(A,T,E,w,y,22,c[7]),w=t(w,A,T,E,g,7,c[8]),E=t(E,w,A,T,b,12,c[9]),T=t(T,E,w,A,v,17,c[10]),A=t(A,T,E,w,m,22,c[11]),w=t(w,A,T,E,_,7,c[12]),E=t(E,w,A,T,S,12,c[13]),T=t(T,E,w,A,O,17,c[14]),w=n(w,A=t(A,T,E,w,P,22,c[15]),T,E,s,5,c[16]),E=n(E,w,A,T,d,9,c[17]),T=n(T,E,w,A,m,14,c[18]),A=n(A,T,E,w,u,20,c[19]),w=n(w,A,T,E,h,5,c[20]),E=n(E,w,A,T,v,9,c[21]),T=n(T,E,w,A,P,14,c[22]),A=n(A,T,E,w,f,20,c[23]),w=n(w,A,T,E,b,5,c[24]),E=n(E,w,A,T,O,9,c[25]),T=n(T,E,w,A,p,14,c[26]),A=n(A,T,E,w,g,20,c[27]),w=n(w,A,T,E,S,5,c[28]),E=n(E,w,A,T,l,9,c[29]),T=n(T,E,w,A,y,14,c[30]),w=r(w,A=n(A,T,E,w,_,20,c[31]),T,E,h,4,c[32]),E=r(E,w,A,T,g,11,c[33]),T=r(T,E,w,A,m,16,c[34]),A=r(A,T,E,w,O,23,c[35]),w=r(w,A,T,E,s,4,c[36]),E=r(E,w,A,T,f,11,c[37]),T=r(T,E,w,A,y,16,c[38]),A=r(A,T,E,w,v,23,c[39]),w=r(w,A,T,E,S,4,c[40]),E=r(E,w,A,T,u,11,c[41]),T=r(T,E,w,A,p,16,c[42]),A=r(A,T,E,w,d,23,c[43]),w=r(w,A,T,E,b,4,c[44]),E=r(E,w,A,T,_,11,c[45]),T=r(T,E,w,A,P,16,c[46]),w=o(w,A=r(A,T,E,w,l,23,c[47]),T,E,u,6,c[48]),E=o(E,w,A,T,y,10,c[49]),T=o(T,E,w,A,O,15,c[50]),A=o(A,T,E,w,h,21,c[51]),w=o(w,A,T,E,_,6,c[52]),E=o(E,w,A,T,p,10,c[53]),T=o(T,E,w,A,v,15,c[54]),A=o(A,T,E,w,s,21,c[55]),w=o(w,A,T,E,g,6,c[56]),E=o(E,w,A,T,P,10,c[57]),T=o(T,E,w,A,d,15,c[58]),A=o(A,T,E,w,S,21,c[59]),w=o(w,A,T,E,f,6,c[60]),E=o(E,w,A,T,m,10,c[61]),T=o(T,E,w,A,l,15,c[62]),A=o(A,T,E,w,b,21,c[63]);a[0]=a[0]+w|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=w,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(u=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),h=(h.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:h}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,f.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=w,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],f=[],h=[],d=0;256>d;d++)h[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var b=(b=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&b^99;r[y]=b,o[b]=y;var v=h[y],m=h[v],_=h[m],S=257*h[b]^16843008*b;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*m^257*v^16843008*y,c[b]=S<<24|S>>>8,l[b]=S<<16|S>>>16,p[b]=S<<8|S>>>24,f[b]=S,y?(y=v^h[h[h[_^v]]],g^=h[h[g]]):y=g=1}var O=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=O[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,f,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],f=e[t+3]^n[3],h=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[f>>>8&255]^a[255&c]^n[h++],b=r[p>>>24]^o[f>>>16&255]^i[c>>>8&255]^a[255&l]^n[h++];f=r[f>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],c=y,l=g,p=b}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[f>>>8&255]<<8|s[255&c])^n[h++],b=(s[p>>>24]<<24|s[f>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],e[t]=y,e[t+1]=g,e[t+2]=b,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}(),w.mode.ECB=((P=w.lib.BlockCipherMode.extend()).Encryptor=P.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),P.Decryptor=P.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),P);var E=w;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function C(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function j(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var M={signPamFromParams:function(e){return j(e).map((function(t){return"".concat(t,"=").concat(C(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:C,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(M.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,f=r(u,["uuid","channel"]);f.user=l,f.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:f})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var h=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(h=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=h.message,y.file={id:h.file.id,name:h.file.name,url:o._getFileUrl({id:h.file.id,name:h.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),I={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},x=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==I.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==I.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case I.PNPublishOperation:t="pub";break;case I.PNSignalOperation:t="sig";break;case I.PNHistoryOperation:case I.PNFetchMessagesOperation:case I.PNDeleteMessagesOperation:case I.PNMessageCounts:t="hist";break;case I.PNUnsubscribeOperation:case I.PNWhereNowOperation:case I.PNHereNowOperation:case I.PNHeartbeatOperation:case I.PNSetStateOperation:case I.PNGetStateOperation:t="pres";break;case I.PNAddChannelsToGroupOperation:case I.PNRemoveChannelsFromGroupOperation:case I.PNChannelGroupsOperation:case I.PNRemoveGroupOperation:case I.PNChannelsForGroupOperation:t="cg";break;case I.PNPushNotificationEnabledChannelsOperation:case I.PNRemoveAllPushNotificationsOperation:t="push";break;case I.PNCreateUserOperation:case I.PNUpdateUserOperation:case I.PNDeleteUserOperation:case I.PNGetUserOperation:case I.PNGetUsersOperation:case I.PNCreateSpaceOperation:case I.PNUpdateSpaceOperation:case I.PNDeleteSpaceOperation:case I.PNGetSpaceOperation:case I.PNGetSpacesOperation:case I.PNGetMembersOperation:case I.PNUpdateMembersOperation:case I.PNGetMembershipsOperation:case I.PNUpdateMembershipsOperation:t="obj";break;case I.PNAddMessageActionOperation:case I.PNRemoveMessageActionOperation:case I.PNGetMessageActionsOperation:t="msga";break;case I.PNAccessManagerGrant:case I.PNAccessManagerAudit:t="pam";break;case I.PNAccessManagerGrantToken:case I.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,f=i.length>0;(l||p||f)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),f&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var h=a.length>0,d=s.length>0,y=u.length>0;return(h||d||y)&&(c.patterns={},h&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(M.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return I.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(M.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return I.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=void 0===o?{}:o,a=e.config,s={};return r.length>0&&(s["channel-group"]=r.join(",")),s.state=JSON.stringify(i),s.heartbeat=a.getPresenceTimeout(),s},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return I.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return I.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(i),"/uuid/").concat(M.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return I.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(M.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var fe=Object.freeze({__proto__:null,getOperation:function(){return I.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return I.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return I.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(M.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return I.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return I.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},be={getOperation:function(){return I.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(M.encodeString(t.channel),"/0/").concat(M.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,f=e.file,h=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,b=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,m,_,S,O,P,w,E,T,A,N,k,C,j,M,R,U,I,x,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!f)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(f),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,m=o.form_fields,_=t.data,S=_.id,O=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return P=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:P=i.sent(),i.label=5;case 5:e=P,i.label=6;case 6:w=m,e.mimeType&&(w=m.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&f.uri?(A=(T=p).POSTFILE,N=[v,w],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,N.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(C=(k=p).POSTFILE,j=[v,w],[4,e.toFile()]):[3,13];case 11:return[4,C.apply(k,j.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(M=p).POSTFILE,U=[v,w],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(M,U.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(x=(I=p).POSTFILE,D=[v,w],[4,e.toBlob()]):[3,19];case 17:return[4,x.apply(I,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:h,fileId:S,fileName:O,meta:y,storeInHistory:b,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:O}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:O})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},me=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(M.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return I.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return I.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},Oe={getOperation:function(){return I.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Pe={getOperation:function(){return I.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},we={getOperation:function(){return I.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return I.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return I.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return I.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return I.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return I.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return I.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,b={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&b.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&b.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&b.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&b.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&b.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&b.include.push("uuid.type")),b.include=b.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(b.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(b.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(b.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(b.filter=t.filter),b.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(b.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),b},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return I.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(M.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&f.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&f.include.push("uuid")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return I.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,b={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&b.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&b.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&b.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&b.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&b.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&b.include.push("channel.type")),b.include=b.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(b.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(b.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(b.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(b.filter=t.filter),b.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(b.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),b},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return I.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(M.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&f.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&f.include.push("channel")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Ue=Object.freeze({__proto__:null,getOperation:function(){return I.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ie=Object.freeze({__proto__:null,getOperation:function(){return I.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,f=void 0!==p&&p,h=t.manage,d=void 0!==h&&h,y=t.get,g=void 0!==y&&y,b=t.join,v=void 0!==b&&b,m=t.update,_=void 0!==m&&m,S=t.authKeys,O=void 0===S?[]:S,P=t.delete,w={};return w.r=l?"1":"0",w.w=f?"1":"0",w.m=d?"1":"0",w.d=P?"1":"0",w.g=g?"1":"0",w.j=v?"1":"0",w.u=_?"1":"0",r.length>0&&(w.channel=r.join(",")),i.length>0&&(w["channel-group"]=i.join(",")),O.length>0&&(w.auth=O.join(",")),s.length>0&&(w["target-uuid"]=s.join(",")),(u||0===u)&&(w.ttl=u),w},handleResponse:function(){return{}}});function xe(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(xe(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,f=o.spaces,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,f=o.channels,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return I.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),f=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),h=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||h||p||d||f||y;return xe(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return I.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(M.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return I.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(M.encodeString(r),"/0/").concat(M.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return I.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(M.encodeString(o),"/0/").concat(M.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return I.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(M.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return I.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(M.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return I.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(M.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return I.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(M.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,f=t.includeUUID,h=void 0===f||f,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),h&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return I.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return I.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return I.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return I.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(M.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=t.timetoken,n.tr=t.region,n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],f=l[1],h=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var b=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=f,this.notify({type:"transitionDone",fromState:b,fromContext:v,toState:p,toContext:f,event:e});try{for(var m=a(h),_=m.next();!_.done;_=m.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=m.return)&&o.call(m)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),O=S.next();!O.done;O=S.next()){g=O.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{O&&!O.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&console.log(e),[2]}))}))}))),r.on(dt.type,lt((function(e,n,a){var s=a.receiveEvents,u=a.shouldRetry,c=a.getRetryDelay,l=a.delay;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(kt())];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region})];case 3:return r=i.sent(),[2,t.transition(At(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Nt(o))]:[3,5];case 5:return[2]}}))}))}))),r.on(yt.type,lt((function(e,n,a){var s=a.handshake,u=a.shouldRetry,c=a.getRetryDelay,l=a.delay;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return u(e.reason,e.attempts)?(n.throwIfAborted(),[4,l(c(e.attempts))]):[2,t.transition(Pt())];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups})];case 3:return r=i.sent(),[2,t.transition(St(r.metadata))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Ot(o))]:[3,5];case 5:return[2]}}))}))}))),r}return t(n,e),n}(tt),Mt=new Ze("STOPPED");Mt.on(gt.type,(function(e,t){return Mt.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(vt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ze("HANDSHAKE_FAILURE");Rt.on(wt.type,(function(e){return Ft.with(n(n({},e),{attempts:0}))})),Rt.on(bt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Ut=new Ze("STOPPED");Ut.on(gt.type,(function(e,t){return Ut.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(vt.type,(function(e){return Dt.with(n({},e))}));var It=new Ze("RECEIVE_FAILURE");It.on(Ct.type,(function(e){return xt.with(n(n({},e),{attempts:0}))})),It.on(bt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var xt=new Ze("RECEIVE_RECONNECTING");xt.onEnter((function(e){return dt(e)})),xt.onExit((function(){return dt.cancel})),xt.on(At.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),xt.on(Nt.type,(function(e,t){return xt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),xt.on(kt.type,(function(e){return It.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason})})),xt.on(bt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var Dt=new Ze("RECEIVING");Dt.onEnter((function(e){return ft(e.channels,e.groups,e.cursor)})),Dt.onExit((function(){return ft.cancel})),Dt.on(Et.type,(function(e,t){return Dt.with(n(n({},e),{cursor:t.payload.cursor}),[ht(t.payload.events)])})),Dt.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Lt.with(void 0):Dt.with(n(n({},e),{channels:t.payload.channels,groups:t.payload.groups}))})),Dt.on(Tt.type,(function(e,t){return xt.with(n(n({},e),{attempts:0,reason:t.payload}))})),Dt.on(bt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}));var Ft=new Ze("HANDSHAKE_RECONNECTING");Ft.onEnter((function(e){return yt(e)})),Ft.onExit((function(){return dt.cancel})),Ft.on(At.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[ht(t.payload.events)])})),Ft.on(Nt.type,(function(e,t){return Ft.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ft.on(kt.type,(function(e){return Rt.with({groups:e.groups,channels:e.channels,reason:e.reason})})),Ft.on(bt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Gt=new Ze("HANDSHAKING");Gt.onEnter((function(e){return pt(e.channels,e.groups)})),Gt.onExit((function(){return pt.cancel})),Gt.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Lt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(mt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload})})),Gt.on(_t.type,(function(e,t){return Ft.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(bt.type,(function(e){return Mt.with({channels:e.channels,groups:e.groups})}));var Lt=new Ze("UNSUBSCRIBED");Lt.on(gt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})}));var Kt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new jt(this.engine,e),this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Lt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(gt(this.channels,this.groups))},e.prototype.unsubscribe=function(e){var t=e.channels,n=e.groups;this.channels=this.channels.filter((function(e){var n;return null===(n=!(null==t?void 0:t.includes(e)))||void 0===n||n})),this.groups=this.groups.filter((function(e){var t;return null===(t=!(null==n?void 0:n.includes(e)))||void 0===t||t})),this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(gt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.reconnect=function(){this.engine.transition(vt())},e.prototype.disconnect=function(){this.engine.transition(bt())},e}(),Bt=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var a=new A({config:i}),c=e.cryptography;r.init(i);var l=new H(i,o);this._tokenManager=l;var p=new x({maximumSamplesCount:6e4});this._telemetryManager=p;var f=this._config.cryptoModule,h={config:i,networking:r,crypto:a,cryptography:c,tokenManager:l,telemetryManager:p,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.encryptFile(t,this.File)):c.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.decryptFile(t,this.File)):c.decryptFile(e,t,this.File)};var d=Q.bind(this,h,Je),y=Q.bind(this,h,ae),b=Q.bind(this,h,ue),m=Q.bind(this,h,le),_=Q.bind(this,h,$e),S=new B;if(this._listenerManager=S,this.iAmHere=Q.bind(this,h,ue),this.iAmAway=Q.bind(this,h,ae),this.setPresenceState=Q.bind(this,h,le),this.handshake=Q.bind(this,h,Qe),this.receiveMessages=Q.bind(this,h,Xe),!0===i.enableSubscribeBeta){var O=new Kt({handshake:this.handshake,receiveEvents:this.receiveMessages});this.subscribe=O.subscribe.bind(O),this.unsubscribe=O.unsubscribe.bind(O),this.eventEngine=O}else{var P=new U({timeEndpoint:d,leaveEndpoint:y,heartbeatEndpoint:b,setStateEndpoint:m,subscribeEndpoint:_,crypto:h.crypto,config:h.config,listenerManager:S,getFileUrl:function(e){return me(h,e)},cryptoModule:h.cryptoModule});this.subscribe=P.adaptSubscribeChange.bind(P),this.unsubscribe=P.adaptUnsubscribeChange.bind(P),this.disconnect=P.disconnect.bind(P),this.reconnect=P.reconnect.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.setState=P.adaptStateChange.bind(P),this.presence=P.adaptPresenceChange.bind(P),this.destroy=function(e){P.unsubscribeAll(e),P.disconnect()}}this.addListener=S.addListener.bind(S),this.removeListener=S.removeListener.bind(S),this.removeAllListeners=S.removeAllListeners.bind(S),this.parseToken=l.parseToken.bind(l),this.setToken=l.setToken.bind(l),this.getToken=l.getToken.bind(l),this.channelGroups={listGroups:Q.bind(this,h,ee),listChannels:Q.bind(this,h,te),addChannels:Q.bind(this,h,X),removeChannels:Q.bind(this,h,Y),deleteGroup:Q.bind(this,h,Z)},this.push={addChannels:Q.bind(this,h,ne),removeChannels:Q.bind(this,h,re),deleteDevice:Q.bind(this,h,ie),listChannels:Q.bind(this,h,oe)},this.hereNow=Q.bind(this,h,pe),this.whereNow=Q.bind(this,h,se),this.getState=Q.bind(this,h,ce),this.grant=Q.bind(this,h,Ie),this.grantToken=Q.bind(this,h,Ge),this.audit=Q.bind(this,h,Ue),this.revokeToken=Q.bind(this,h,Le),this.publish=Q.bind(this,h,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,h,He),this.history=Q.bind(this,h,qe),this.deleteMessages=Q.bind(this,h,ze),this.messageCounts=Q.bind(this,h,Ve),this.fetchMessages=Q.bind(this,h,We),this.addMessageAction=Q.bind(this,h,fe),this.removeMessageAction=Q.bind(this,h,he),this.getMessageActions=Q.bind(this,h,de),this.listFiles=Q.bind(this,h,ye);var w=Q.bind(this,h,ge);this.publishFile=Q.bind(this,h,be),this.sendFile=ve({generateUploadUrl:w,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return me(h,e)},this.downloadFile=Q.bind(this,h,_e),this.deleteFile=Q.bind(this,h,Se),this.objects={getAllUUIDMetadata:Q.bind(this,h,Oe),getUUIDMetadata:Q.bind(this,h,Pe),setUUIDMetadata:Q.bind(this,h,we),removeUUIDMetadata:Q.bind(this,h,Ee),getAllChannelMetadata:Q.bind(this,h,Te),getChannelMetadata:Q.bind(this,h,Ae),setChannelMetadata:Q.bind(this,h,Ne),removeChannelMetadata:Q.bind(this,h,ke),getChannelMembers:Q.bind(this,h,Ce),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function qt(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?qt(a):a})),n}var zt=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),Vt={exports:{}},Wt={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void tn($t,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void tn($t,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function on(e,t,n,r){void 0===r&&(r=Zt());var o,i=an(e,"",0,[],void 0,0,r)||e;try{o=0===Yt.length?JSON.stringify(i,t,n):JSON.stringify(i,sn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Xt.length;){var a=Xt.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function an(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void tn($t,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void tn($t,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new _n('"allowMissing" argument must be a boolean');var n=Ln(e),r=n.length>0?n[0]:"",o=Kn("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],In(n,Un([0,1],u)));for(var c=1,l=!0;c=n.length){var d=On(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=Rn(a,p),a=a[p];l&&!s&&(kn[i]=a)}}return a},Hn={exports:{}};!function(e){var t=gn,n=Bn,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(Hn);var qn=Bn,zn=Hn.exports,Vn=zn(qn("String.prototype.indexOf")),Wn=l(Object.freeze({__proto__:null,default:{}})),Jn="function"==typeof Map&&Map.prototype,$n=Object.getOwnPropertyDescriptor&&Jn?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Qn=Jn&&$n&&"function"==typeof $n.get?$n.get:null,Xn=Jn&&Map.prototype.forEach,Yn="function"==typeof Set&&Set.prototype,Zn=Object.getOwnPropertyDescriptor&&Yn?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,er=Yn&&Zn&&"function"==typeof Zn.get?Zn.get:null,tr=Yn&&Set.prototype.forEach,nr="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,rr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,or="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,ir=Boolean.prototype.valueOf,ar=Object.prototype.toString,sr=Function.prototype.toString,ur=String.prototype.match,cr=String.prototype.slice,lr=String.prototype.replace,pr=String.prototype.toUpperCase,fr=String.prototype.toLowerCase,hr=RegExp.prototype.test,dr=Array.prototype.concat,yr=Array.prototype.join,gr=Array.prototype.slice,br=Math.floor,vr="function"==typeof BigInt?BigInt.prototype.valueOf:null,mr=Object.getOwnPropertySymbols,_r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Sr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Or="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Sr||"symbol")?Symbol.toStringTag:null,Pr=Object.prototype.propertyIsEnumerable,wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Er(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||hr.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-br(-e):br(e);if(r!==e){var o=String(r),i=cr.call(t,o.length+1);return lr.call(o,n,"$&_")+"."+lr.call(lr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return lr.call(t,n,"$&_")}var Tr=Wn,Ar=Tr.custom,Nr=Rr(Ar)?Ar:null;function kr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Cr(e){return lr.call(String(e),/"/g,""")}function jr(e){return!("[object Array]"!==xr(e)||Or&&"object"==typeof e&&Or in e)}function Mr(e){return!("[object RegExp]"!==xr(e)||Or&&"object"==typeof e&&Or in e)}function Rr(e){if(Sr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!_r)return!1;try{return _r.call(e),!0}catch(e){}return!1}var Ur=Object.prototype.hasOwnProperty||function(e){return e in this};function Ir(e,t){return Ur.call(e,t)}function xr(e){return ar.call(e)}function Dr(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return Fr(cr.call(e,0,t.maxStringLength),t)+r}return kr(lr.call(lr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Gr),"single",t)}function Gr(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+pr.call(t.toString(16))}function Lr(e){return"Object("+e+")"}function Kr(e){return e+" { ? }"}function Br(e,t,n,r){return e+" ("+t+") {"+(r?Hr(n,r):yr.call(n,", "))+"}"}function Hr(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+yr.call(e,","+n)+"\n"+t.prev}function qr(e,t){var n=jr(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?zn(n):n},Wr=function e(t,n,r,o){var i=n||{};if(Ir(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ir(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!Ir(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ir(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ir(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return Fr(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Er(t,u):u}if("bigint"==typeof t){var c=String(t)+"n";return s?Er(t,c):c}var l=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=l&&l>0&&"object"==typeof t)return jr(t)?"[Array]":"[Object]";var p=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=yr.call(Array(e.indent+1)," ")}return{base:n,prev:yr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(Dr(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=gr.call(o)).push(n),a){var s={depth:i.depth};return Ir(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!Mr(t)){var h=function(e){if(e.name)return e.name;var t=ur.call(sr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),d=qr(t,f);return"[Function"+(h?": "+h:" (anonymous)")+"]"+(d.length>0?" { "+yr.call(d,", ")+" }":"")}if(Rr(t)){var y=Sr?lr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):_r.call(t);return"object"!=typeof t||Sr?y:Lr(y)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var g="<"+fr.call(String(t.nodeName)),b=t.attributes||[],v=0;v"}if(jr(t)){if(0===t.length)return"[]";var m=qr(t,f);return p&&!function(e){for(var t=0;t=0)return!1;return!0}(m)?"["+Hr(m,p)+"]":"[ "+yr.call(m,", ")+" ]"}if(function(e){return!("[object Error]"!==xr(e)||Or&&"object"==typeof e&&Or in e)}(t)){var _=qr(t,f);return"cause"in Error.prototype||!("cause"in t)||Pr.call(t,"cause")?0===_.length?"["+String(t)+"]":"{ ["+String(t)+"] "+yr.call(_,", ")+" }":"{ ["+String(t)+"] "+yr.call(dr.call("[cause]: "+f(t.cause),_),", ")+" }"}if("object"==typeof t&&a){if(Nr&&"function"==typeof t[Nr]&&Tr)return Tr(t,{depth:l-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!Qn||!e||"object"!=typeof e)return!1;try{Qn.call(e);try{er.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var S=[];return Xn&&Xn.call(t,(function(e,n){S.push(f(n,t,!0)+" => "+f(e,t))})),Br("Map",Qn.call(t),S,p)}if(function(e){if(!er||!e||"object"!=typeof e)return!1;try{er.call(e);try{Qn.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return tr&&tr.call(t,(function(e){O.push(f(e,t))})),Br("Set",er.call(t),O,p)}if(function(e){if(!nr||!e||"object"!=typeof e)return!1;try{nr.call(e,nr);try{rr.call(e,rr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return Kr("WeakMap");if(function(e){if(!rr||!e||"object"!=typeof e)return!1;try{rr.call(e,rr);try{nr.call(e,nr)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return Kr("WeakSet");if(function(e){if(!or||!e||"object"!=typeof e)return!1;try{return or.call(e),!0}catch(e){}return!1}(t))return Kr("WeakRef");if(function(e){return!("[object Number]"!==xr(e)||Or&&"object"==typeof e&&Or in e)}(t))return Lr(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!vr)return!1;try{return vr.call(e),!0}catch(e){}return!1}(t))return Lr(f(vr.call(t)));if(function(e){return!("[object Boolean]"!==xr(e)||Or&&"object"==typeof e&&Or in e)}(t))return Lr(ir.call(t));if(function(e){return!("[object String]"!==xr(e)||Or&&"object"==typeof e&&Or in e)}(t))return Lr(f(String(t)));if(!function(e){return!("[object Date]"!==xr(e)||Or&&"object"==typeof e&&Or in e)}(t)&&!Mr(t)){var P=qr(t,f),w=wr?wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,E=t instanceof Object?"":"null prototype",T=!w&&Or&&Object(t)===t&&Or in t?cr.call(xr(t),8,-1):E?"Object":"",A=(w||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(T||E?"["+yr.call(dr.call([],T||[],E||[]),": ")+"] ":"");return 0===P.length?A+"{}":p?A+"{"+Hr(P,p)+"}":A+"{ "+yr.call(P,", ")+" }"}return String(t)},Jr=zr("%TypeError%"),$r=zr("%WeakMap%",!0),Qr=zr("%Map%",!0),Xr=Vr("WeakMap.prototype.get",!0),Yr=Vr("WeakMap.prototype.set",!0),Zr=Vr("WeakMap.prototype.has",!0),eo=Vr("Map.prototype.get",!0),to=Vr("Map.prototype.set",!0),no=Vr("Map.prototype.has",!0),ro=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},oo=String.prototype.replace,io=/%20/g,ao="RFC3986",so={default:ao,formatters:{RFC1738:function(e){return oo.call(e,io,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:ao},uo=so,co=Object.prototype.hasOwnProperty,lo=Array.isArray,po=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),fo=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(lo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===uo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=po[u]:u<2048?a+=po[192|u>>6]+po[128|63&u]:u<55296||u>=57344?a+=po[224|u>>12]+po[128|u>>6&63]+po[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=po[240|u>>18]+po[128|u>>12&63]+po[128|u>>6&63]+po[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(lo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(_o(u))P=u;else{var E=Object.keys(v);P=c?E.sort(c):E}for(var T=o&&_o(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},Uo=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&ko.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},Io=function(e,t){var n,r=e,o=function(e){if(!e)return Eo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Eo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=bo.default;if(void 0!==e.format){if(!vo.call(bo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=bo.formatters[n],o=Eo.filter;return("function"==typeof e.filter||_o(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Eo.addQueryPrefix,allowDots:void 0===e.allowDots?Eo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Eo.charsetSentinel,delimiter:void 0===e.delimiter?Eo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Eo.encode,encoder:"function"==typeof e.encoder?e.encoder:Eo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Eo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Eo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Eo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Eo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):_o(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in mo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=mo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=yo(),l=0;l0?h+f:""},xo={formats:so,parse:function(e,t){var n=function(e){if(!e)return jo;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?jo.charset:e.charset;return{allowDots:void 0===e.allowDots?jo.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:jo.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:jo.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:jo.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:jo.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:jo.comma,decoder:"function"==typeof e.decoder?e.decoder:jo.decoder,delimiter:"string"==typeof e.delimiter||No.isRegExp(e.delimiter)?e.delimiter:jo.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:jo.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:jo.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:jo.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:jo.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:jo.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Co(l)?[l]:l),ko.call(r,c)?r[c]=No.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(Do);const Fo=Wn,Go=Do.isObject,Lo=Do.hasOwn;var Ko=Bo;function Bo(){}Bo.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},Bo.prototype.parse=function(e){return this._parser=e,this},Bo.prototype.responseType=function(e){return this._responseType=e,this},Bo.prototype.serialize=function(e){return this._serializer=e,this},Bo.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(Lo(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},Bo.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const Ho=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),qo=new Set([408,413,429,500,502,503,504,521,522,524]);Bo.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&qo.has(t.status))return!0;if(e){if(e.code&&Ho.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},Bo.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},Bo.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},Bo.prototype.catch=function(e){return this.then(void 0,e)},Bo.prototype.use=function(e){return e(this),this},Bo.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},Bo.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},Bo.prototype.get=function(e){return this._header[e.toLowerCase()]},Bo.prototype.getHeader=Bo.prototype.get,Bo.prototype.set=function(e,t){if(Go(e)){for(const t in e)Lo(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},Bo.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},Bo.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Go(e)){for(const t in e)Lo(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)Lo(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},Bo.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(Fo.gte(process.version,"v13.0.0")&&Fo.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},Bo.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},Bo.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},Bo.prototype.redirects=function(e){return this._maxRedirects=e,this},Bo.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},Bo.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},Bo.prototype.send=function(e){const t=Go(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&Go(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");Lo(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},Bo.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},Bo.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},Bo.prototype._appendQueryString=()=>{console.warn("Unsupported")},Bo.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},Bo.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const zo=Do;var Vo=Wo;function Wo(){}function Jo(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function $o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function b(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function m(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=b,y.parseString=m,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":m,"application/json":JSON.parse},l(S.prototype,f.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(O.prototype),l(O.prototype,u.prototype),O.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},O.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},O.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},O.prototype.query=function(e){return"string"!=typeof e&&(e=b(e)),e&&this._query.push(e),this},O.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},O.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},O.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},O.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},O.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},O.prototype.ca=O.prototype.agent,O.prototype.buffer=O.prototype.ca,O.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},O.prototype.pipe=O.prototype.write,O.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},O.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},O.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},O.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new h;for(var P=0,w=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];P{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(Vt,Vt.exports);var ei=Vt.exports;function ti(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function ni(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(ti)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function ri(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=ei.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function oi(e,t,n){var r=ei.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ni.call(this,r,t,n)}function ii(e,t,n){var r=ei.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ni.call(this,r,t,n)}function ai(e,t,n,r){var o=ei.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ni.call(this,o,n,r)}function si(e,t,n,r){var o=ei.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return ni.call(this,o,n,r)}function ui(e,t,n){var r=ei.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ni.call(this,r,t,n)}function ci(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var li,pi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ci,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ci(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),fi=(li=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),li.supportsFile="undefined"!=typeof File,li.supportsBlob="undefined"!=typeof Blob,li.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,li.supportsBuffer=!1,li.supportsStream=!1,li.supportsString=!0,li.supportsEncryptFile=!0,li.supportsFileUri=!1,li),hi=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new pi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:b(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof bi)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new bi(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new bi(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),bi=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return gi.SENTINEL.length+1+gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(gi.SENTINEL)),t[e+=gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function vi(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var mi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new Ht({del:ui,get:ii,post:ai,patch:si,sendBeacon:vi,getfile:oi,postfile:ri}),t.cbor=new zt((function(e){return qt(f.decode(e))}),b),t.PubNubFile=fi,t.cryptography=new pi,t.initCryptoModule=function(e){return new yi({default:new hi({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=yi,n}(Bt);return mi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var d=h.exports,y=function(){return d.uuid?d.uuid():d()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this.setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype.setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,h=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=f,64!=l&&(o[s+1]=h),64!=p&&(o[s+2]=d)}return r}function b(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var v,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),f=2;f<=p;f++)if(!(l%f)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var h=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],f=0;64>f;f++){if(16>f)h[f]=0|e[t+f];else{var d=h[f-15],y=h[f-2];h[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+h[f-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+h[f-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+h[f],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],f=e[i+4],h=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],b=e[i+10],v=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,f,7,c[4]),E=t(E,P,A,T,h,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,b,17,c[10]),A=t(A,T,E,P,v,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,v,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,h,5,c[20]),E=n(E,P,A,T,b,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,f,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,h,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,v,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,f,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,b,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,h,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,b,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,f,6,c[60]),E=o(E,P,A,T,v,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(u=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),h=(h.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:h}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,f.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],f=[],h=[],d=0;256>d;d++)h[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var b=h[y],v=h[b],_=h[v],S=257*h[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*v^257*b^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,f[m]=S,y?(y=b^h[h[h[_^b]]],g^=h[h[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,f,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],f=e[t+3]^n[3],h=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[f>>>8&255]^a[255&c]^n[h++],m=r[p>>>24]^o[f>>>16&255]^i[c>>>8&255]^a[255&l]^n[h++];f=r[f>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[f>>>8&255]<<8|s[255&c])^n[h++],m=(s[p>>>24]<<24|s[f>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,f=r(u,["uuid","channel"]);f.user=l,f.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:f})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var h=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(h=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=h.message,y.file={id:h.file.id,name:h.file.name,url:o._getFileUrl({id:h.file.id,name:h.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),x={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==x.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==x.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case x.PNPublishOperation:t="pub";break;case x.PNSignalOperation:t="sig";break;case x.PNHistoryOperation:case x.PNFetchMessagesOperation:case x.PNDeleteMessagesOperation:case x.PNMessageCounts:t="hist";break;case x.PNUnsubscribeOperation:case x.PNWhereNowOperation:case x.PNHereNowOperation:case x.PNHeartbeatOperation:case x.PNSetStateOperation:case x.PNGetStateOperation:t="pres";break;case x.PNAddChannelsToGroupOperation:case x.PNRemoveChannelsFromGroupOperation:case x.PNChannelGroupsOperation:case x.PNRemoveGroupOperation:case x.PNChannelsForGroupOperation:t="cg";break;case x.PNPushNotificationEnabledChannelsOperation:case x.PNRemoveAllPushNotificationsOperation:t="push";break;case x.PNCreateUserOperation:case x.PNUpdateUserOperation:case x.PNDeleteUserOperation:case x.PNGetUserOperation:case x.PNGetUsersOperation:case x.PNCreateSpaceOperation:case x.PNUpdateSpaceOperation:case x.PNDeleteSpaceOperation:case x.PNGetSpaceOperation:case x.PNGetSpacesOperation:case x.PNGetMembersOperation:case x.PNUpdateMembersOperation:case x.PNGetMembershipsOperation:case x.PNUpdateMembershipsOperation:t="obj";break;case x.PNAddMessageActionOperation:case x.PNRemoveMessageActionOperation:case x.PNGetMessageActionsOperation:t="msga";break;case x.PNAccessManagerGrant:case x.PNAccessManagerAudit:t="pam";break;case x.PNAccessManagerGrantToken:case x.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,f=i.length>0;(l||p||f)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),f&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var h=a.length>0,d=s.length>0,y=u.length>0;return(h||d||y)&&(c.patterns={},h&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return x.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return x.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return x.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return x.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return x.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var fe=Object.freeze({__proto__:null,getOperation:function(){return x.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return x.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return x.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return x.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return x.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return x.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:b(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},be=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,f=e.file,h=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,b,v,_,S,w,O,P,E,T,A,C,k,N,M,j,R,U,x,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!f)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(f),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,b=o.url,v=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=v,e.mimeType&&(P=v.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&f.uri?(A=(T=p).POSTFILE,C=[b,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[b,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,U=[b,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,U.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(x=p).POSTFILE,D=[b,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(x,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:h,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return x.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return x.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return x.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return x.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return x.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return x.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return x.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return x.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return x.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return x.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return x.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return x.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&f.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&f.include.push("uuid")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return x.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return x.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&f.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&f.include.push("channel")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Ue=Object.freeze({__proto__:null,getOperation:function(){return x.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var xe=Object.freeze({__proto__:null,getOperation:function(){return x.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,f=void 0!==p&&p,h=t.manage,d=void 0!==h&&h,y=t.get,g=void 0!==y&&y,m=t.join,b=void 0!==m&&m,v=t.update,_=void 0!==v&&v,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=f?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=b?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,f=o.spaces,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,f=o.channels,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return x.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),f=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),h=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||h||p||d||f||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return x.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:b(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return x.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return x.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return x.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return x.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return x.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return x.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,f=t.includeUUID,h=void 0===f||f,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),h&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return x.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return x.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return x.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return x.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],f=l[1],h=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=f,this.notify({type:"transitionDone",fromState:m,fromContext:b,toState:p,toContext:f,event:e});try{for(var v=a(h),_=v.next();!_.done;_=v.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=v.return)&&o.call(v)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&a(e),[2]}))}))}))),r.on(ft.type,ut((function(e,t,n){var a=n.emitStatus;return o(r,void 0,void 0,(function(){return i(this,(function(t){return a(e),[2]}))}))}))),r.on(ht.type,ut((function(e,n,a){var s=a.receiveEvents,u=a.delay,c=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Tt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(At(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Ct())];case 7:return[2]}}))}))}))),r.on(dt.type,ut((function(e,n,a){var s=a.handshake,u=a.delay,c=a.presenceState,l=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,filterExpression:l.filterExpression,state:c})];case 3:return r=i.sent(),[2,t.transition(St(r))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Ot())];case 7:return[2]}}))}))}))),r}return t(n,e),n}(tt),jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),jt.on(mt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ze("HANDSHAKE_FAILURE");Rt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Rt.on(mt.type,(function(e){return Gt.with(n({},e))}));var Ut=new Ze("STOPPED");Ut.on(yt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(bt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(mt.type,(function(e){return Gt.with({channels:e.channels,groups:e.groups})})),Ut.on(Nt.type,(function(){return Lt.with(void 0)}));var xt=new Ze("RECEIVE_FAILED");xt.on(kt.type,(function(e){return Gt.with({channels:e.channels,groups:e.groups,timetoken:e.cursor.timetoken})})),xt.on(gt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),xt.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),xt.on(Nt.type,(function(e){return Lt.with(void 0)}));var It=new Ze("RECEIVE_RECONNECTING");It.onEnter((function(e){return ht(e)})),It.onExit((function(){return ht.cancel})),It.on(Tt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(At.type,(function(e,t){return It.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),It.on(Ct.type,(function(e){return xt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[ft({category:R.PNDisconnectedUnexpectedlyCategory})])})),It.on(gt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),It.on(bt.type,(function(e,t){var n,r;return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:null!==(n=t.payload.timetoken)&&void 0!==n?n:e.cursor.timetoken,region:null!==(r=t.payload.region)&&void 0!==r?r:e.cursor.region}})})),It.on(yt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),It.on(Nt.type,(function(e){return Lt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("RECEIVING");Dt.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),Dt.onExit((function(){return lt.cancel})),Dt.on(Pt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Dt.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Lt.with(void 0):Dt.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(Et.type,(function(e,t){return It.with(n(n({},e),{attempts:0,reason:t.payload}))})),Dt.on(gt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),Dt.on(Nt.type,(function(e){return Lt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Ft=new Ze("HANDSHAKE_RECONNECTING");Ft.onEnter((function(e){return dt(e)})),Ft.onExit((function(){return dt.cancel})),Ft.on(St.type,(function(e,t){var n=e.timetoken?{timetoken:e.timetoken,region:1}:t.payload.cursor;return Dt.with({channels:e.channels,groups:e.groups,cursor:n},[ft({category:R.PNConnectedCategory})])})),Ft.on(wt.type,(function(e,t){return Ft.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ft.on(Ot.type,(function(e){return Rt.with({groups:e.groups,channels:e.channels,reason:e.reason},[ft({category:R.PNConnectionErrorCategory})])})),Ft.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups},[ft({category:R.PNDisconnectedCategory})])})),Ft.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(Nt.type,(function(e){return Lt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Gt=new Ze("HANDSHAKING");Gt.onEnter((function(e){return ct(e.channels,e.groups)})),Gt.onExit((function(){return ct.cancel})),Gt.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Lt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:{timetoken:e.timetoken&&"0"!==e.timetoken?e.timetoken:t.payload.timetoken,region:t.payload.region}},[ft({category:R.PNConnectedCategory})])})),Gt.on(_t.type,(function(e,t){return Ft.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Gt.on(Nt.type,(function(e){return Lt.with()})),Gt.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Lt=new Ze("UNSUBSCRIBED");Lt.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),Lt.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Kt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Mt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Lt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(bt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(){this.engine.transition(mt())},e.prototype.disconnect=function(){this.engine.transition(gt()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Bt=nt("RECONNECT",(function(){return{}})),Ht=nt("DISCONNECT",(function(){return{}})),qt=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),Vt=nt("LEFT_ALL",(function(){return{}})),Wt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Jt=nt("HEARTBEAT_FAILURE",(function(e){return e})),$t=nt("HEARTBEAT_GIVEUP",(function(){return{}})),Qt=nt("TIMES_UP",(function(){return{}})),Xt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Yt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Zt=rt("EMIT_STATUS",(function(e){return e})),en=ot("WAIT",(function(){return{}})),tn=ot("DELAYED_HEARTBEAT",(function(e){return e})),nn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Xt.type,ut((function(e,n,r){var s=r.heartbeat,u=r.presenceState;return o(a,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,s({channels:e.channels,channelGroups:e.groups,state:u})];case 1:return n=o.sent(),console.log("heartbeat Success: result = ",n,"\n\n",JSON.stringify(n)),t.transition(Wt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Jt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(en.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition(Qt())]}}))}))}))),a.on(tn.type,ut((function(e,n,r){var s=r.heartbeat,u=r.retryDelay,c=r.presenceState,l=r.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,s({channels:e.channels,channelGroups:e.groups,state:c})];case 3:return o.sent(),[2,t.transition(Wt(200))];case 4:return(r=o.sent())instanceof Error&&"Aborted"===r.message?[2]:r instanceof q?[2,t.transition(Jt(r))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition($t())];case 7:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?(console.log("failed => payload.status :",e.status),s(e.status)):u.announceSuccessfulHeartbeats&&200===e.statusCode&&(console.log("need to announce... received event.payload = ",e),s(n(n({},e),{operation:x.PNHeartbeatOperation,error:!1}))),[2]}))}))}))),a}return t(r,e),r}(tt),rn=new Ze("HEARTBEAT_STOPPED");rn.on(qt.type,(function(e,t){return rn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(zt.type,(function(e,t){return rn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e,t){return un.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),rn.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var on=new Ze("HEARTBEATCOOLDOWN");on.onEnter((function(){return en()})),on.onExit((function(){return en.cancel})),on.on(Qt.type,(function(e,t){return un.with({channels:e.channels,groups:e.groups})})),on.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),on.on(Ht.type,(function(e){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),on.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var an=new Ze("HEARTBEAT_FAILED");an.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){return un.with({channels:e.channels,groups:e.groups})})),an.on(Ht.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var sn=new Ze("HEARBEAT_RECONNECTING");sn.onEnter((function(e){return tn(e)})),sn.onExit((function(){return tn.cancel})),sn.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),sn.on(Ht.type,(function(e,t){rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),sn.on(Wt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),sn.on(Jt.type,(function(e,t){return sn.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),sn.on($t.type,(function(e,t){return an.with({channels:e.channels,groups:e.groups})})),sn.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var un=new Ze("HEARTBEATING");un.onEnter((function(e){return Xt(e.channels,e.groups)})),un.on(Wt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups},[Zt(t.payload)])})),un.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),un.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),un.on(Jt.type,(function(e,t){return sn.with(n(n({},e),{attempts:0,reason:t.payload}),[Zt(t.payload)])})),un.on(Ht.type,(function(e){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),un.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var cn=new Ze("HEARTBEAT_INACTIVE");cn.on(qt.type,(function(e,t){return un.with({channels:t.payload.channels,groups:t.payload.groups})})),cn.on(zt.type,(function(e,t){return cn.with()}));var ln=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new nn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(cn,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(qt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(zt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(Vt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),pn=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){return 1e3*this.delay}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){var t=1e3*Math.trunc(Math.pow(2,e))+1e3*Math.random();return t>15e4?15e4:t}}},e}(),fn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var f=e.payload;if(this.modules.cryptoModule){var h=void 0;try{h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=f.message,a.file={id:f.file.id,name:f.file.name,url:this.getFileUrl({id:f.file.id,name:f.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){h=void 0;try{var d;h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=h?h:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype.emitStatus=function(e){},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var f=new I({maximumSamplesCount:6e4});this._telemetryManager=f;var h=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:f,PubNubFile:e.PubNubFile,cryptoModule:h};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),v=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new fn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return ve(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new ln({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Kt({handshake:this.handshake,receiveEvents:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitEvents:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.eventEngine=P}else{var E=new U({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:v,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return ve(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,xe),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,Ue),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,fe),this.removeMessageAction=Q.bind(this,d,he),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=be({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return ve(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function yn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?yn(a):a})),n}var gn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),mn={exports:{}},bn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void Tn(_n,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void Tn(_n,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=Pn());var o,i=Nn(e,"",0,[],void 0,0,r)||e;try{o=0===On.length?JSON.stringify(i,t,n):JSON.stringify(i,Mn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wn.length;){var a=wn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Nn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void Tn(_n,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void Tn(_n,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new qn('"allowMissing" argument must be a boolean');var n=lr(e),r=n.length>0?n[0]:"",o=pr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],ir(n,or([0,1],u)));for(var c=1,l=!0;c=n.length){var d=Vn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=rr(a,p),a=a[p];l&&!s&&(Zn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Ln,n=fr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var dr=fr,yr=hr.exports,gr=yr(dr("String.prototype.indexOf")),mr=l(Object.freeze({__proto__:null,default:{}})),br="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&br?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,_r=br&&vr&&"function"==typeof vr.get?vr.get:null,Sr=br&&Map.prototype.forEach,wr="function"==typeof Set&&Set.prototype,Or=Object.getOwnPropertyDescriptor&&wr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Pr=wr&&Or&&"function"==typeof Or.get?Or.get:null,Er=wr&&Set.prototype.forEach,Tr="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Ar="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Cr="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Nr=Object.prototype.toString,Mr=Function.prototype.toString,jr=String.prototype.match,Rr=String.prototype.slice,Ur=String.prototype.replace,xr=String.prototype.toUpperCase,Ir=String.prototype.toLowerCase,Dr=RegExp.prototype.test,Fr=Array.prototype.concat,Gr=Array.prototype.join,Lr=Array.prototype.slice,Kr=Math.floor,Br="function"==typeof BigInt?BigInt.prototype.valueOf:null,Hr=Object.getOwnPropertySymbols,qr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,zr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Vr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===zr||"symbol")?Symbol.toStringTag:null,Wr=Object.prototype.propertyIsEnumerable,Jr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function $r(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Dr.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Kr(-e):Kr(e);if(r!==e){var o=String(r),i=Rr.call(t,o.length+1);return Ur.call(o,n,"$&_")+"."+Ur.call(Ur.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Ur.call(t,n,"$&_")}var Qr=mr,Xr=Qr.custom,Yr=ro(Xr)?Xr:null;function Zr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function eo(e){return Ur.call(String(e),/"/g,""")}function to(e){return!("[object Array]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}function no(e){return!("[object RegExp]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}function ro(e){if(zr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!qr)return!1;try{return qr.call(e),!0}catch(e){}return!1}var oo=Object.prototype.hasOwnProperty||function(e){return e in this};function io(e,t){return oo.call(e,t)}function ao(e){return Nr.call(e)}function so(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return uo(Rr.call(e,0,t.maxStringLength),t)+r}return Zr(Ur.call(Ur.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,co),"single",t)}function co(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function lo(e){return"Object("+e+")"}function po(e){return e+" { ? }"}function fo(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Gr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Gr.call(e,","+n)+"\n"+t.prev}function yo(e,t){var n=to(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?yr(n):n},bo=function e(t,n,r,o){var i=n||{};if(io(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(io(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!io(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(io(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(io(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return uo(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?$r(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?$r(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return to(t)?"[Array]":"[Object]";var f=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Gr.call(Array(e.indent+1)," ")}return{base:n,prev:Gr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(so(o,t)>=0)return"[Circular]";function h(t,n,a){if(n&&(o=Lr.call(o)).push(n),a){var s={depth:i.depth};return io(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!no(t)){var d=function(e){if(e.name)return e.name;var t=jr.call(Mr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=yo(t,h);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Gr.call(y,", ")+" }":"")}if(ro(t)){var g=zr?Ur.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):qr.call(t);return"object"!=typeof t||zr?g:lo(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ir.call(String(t.nodeName)),b=t.attributes||[],v=0;v"}if(to(t)){if(0===t.length)return"[]";var _=yo(t,h);return f&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,f)+"]":"[ "+Gr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t)){var S=yo(t,h);return"cause"in Error.prototype||!("cause"in t)||Wr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Gr.call(S,", ")+" }":"{ ["+String(t)+"] "+Gr.call(Fr.call("[cause]: "+h(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Yr&&"function"==typeof t[Yr]&&Qr)return Qr(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!_r||!e||"object"!=typeof e)return!1;try{_r.call(e);try{Pr.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return Sr&&Sr.call(t,(function(e,n){w.push(h(n,t,!0)+" => "+h(e,t))})),fo("Map",_r.call(t),w,f)}if(function(e){if(!Pr||!e||"object"!=typeof e)return!1;try{Pr.call(e);try{_r.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Er&&Er.call(t,(function(e){O.push(h(e,t))})),fo("Set",Pr.call(t),O,f)}if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Ar.call(e,Ar)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return po("WeakMap");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{Ar.call(e,Ar);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return po("WeakSet");if(function(e){if(!Cr||!e||"object"!=typeof e)return!1;try{return Cr.call(e),!0}catch(e){}return!1}(t))return po("WeakRef");if(function(e){return!("[object Number]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t))return lo(h(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Br)return!1;try{return Br.call(e),!0}catch(e){}return!1}(t))return lo(h(Br.call(t)));if(function(e){return!("[object Boolean]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t))return lo(kr.call(t));if(function(e){return!("[object String]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t))return lo(h(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t)&&!no(t)){var P=yo(t,h),E=Jr?Jr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&Vr&&Object(t)===t&&Vr in t?Rr.call(ao(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Gr.call(Fr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":f?C+"{"+ho(P,f)+"}":C+"{ "+Gr.call(P,", ")+" }"}return String(t)},vo=go("%TypeError%"),_o=go("%WeakMap%",!0),So=go("%Map%",!0),wo=mo("WeakMap.prototype.get",!0),Oo=mo("WeakMap.prototype.set",!0),Po=mo("WeakMap.prototype.has",!0),Eo=mo("Map.prototype.get",!0),To=mo("Map.prototype.set",!0),Ao=mo("Map.prototype.has",!0),Co=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,No=/%20/g,Mo="RFC3986",jo={default:Mo,formatters:{RFC1738:function(e){return ko.call(e,No,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:Mo},Ro=jo,Uo=Object.prototype.hasOwnProperty,xo=Array.isArray,Io=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Do=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===Ro.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Io[u]:u<2048?a+=Io[192|u>>6]+Io[128|63&u]:u<55296||u>=57344?a+=Io[224|u>>12]+Io[128|u>>6&63]+Io[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Io[240|u>>18]+Io[128|u>>12&63]+Io[128|u>>6&63]+Io[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?b.join(",")||null:void 0}];else if(qo(u))O=u;else{var E=Object.keys(b);O=c?E.sort(c):E}for(var T=o&&qo(b)&&1===b.length?n+"[]":n,A=0;A-1?e.split(","):e},oi=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Zo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},ii=function(e,t){var n,r=e,o=function(e){if(!e)return $o;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||$o.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Ko.default;if(void 0!==e.format){if(!Bo.call(Ko.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Ko.formatters[n],o=$o.filter;return("function"==typeof e.filter||qo(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:$o.addQueryPrefix,allowDots:void 0===e.allowDots?$o.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:$o.charsetSentinel,delimiter:void 0===e.delimiter?$o.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:$o.encode,encoder:"function"==typeof e.encoder?e.encoder:$o.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:$o.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:$o.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:$o.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:$o.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):qo(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Ho?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Ho[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Go(),l=0;l0?h+f:""},ai={formats:jo,parse:function(e,t){var n=function(e){if(!e)return ti;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ti.charset:e.charset;return{allowDots:void 0===e.allowDots?ti.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ti.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ti.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ti.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ti.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ti.comma,decoder:"function"==typeof e.decoder?e.decoder:ti.decoder,delimiter:"string"==typeof e.delimiter||Yo.isRegExp(e.delimiter)?e.delimiter:ti.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ti.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ti.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ti.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ti.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ti.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=ei(l)?[l]:l),Zo.call(r,c)?r[c]=Yo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(si);const ui=mr,ci=si.isObject,li=si.hasOwn;var pi=fi;function fi(){}fi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},fi.prototype.parse=function(e){return this._parser=e,this},fi.prototype.responseType=function(e){return this._responseType=e,this},fi.prototype.serialize=function(e){return this._serializer=e,this},fi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(li(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},fi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),di=new Set([408,413,429,500,502,503,504,521,522,524]);fi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&di.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},fi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},fi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},fi.prototype.catch=function(e){return this.then(void 0,e)},fi.prototype.use=function(e){return e(this),this},fi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},fi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},fi.prototype.get=function(e){return this._header[e.toLowerCase()]},fi.prototype.getHeader=fi.prototype.get,fi.prototype.set=function(e,t){if(ci(e)){for(const t in e)li(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},fi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},fi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ci(e)){for(const t in e)li(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)li(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},fi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(ui.gte(process.version,"v13.0.0")&&ui.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},fi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},fi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},fi.prototype.redirects=function(e){return this._maxRedirects=e,this},fi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},fi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},fi.prototype.send=function(e){const t=ci(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ci(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");li(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},fi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},fi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},fi.prototype._appendQueryString=()=>{console.warn("Unsupported")},fi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},fi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const yi=si;var gi=mi;function mi(){}function bi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&b(t,n,e[n]);return t.join("&")}function b(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){b(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&b(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function v(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=v,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":v,"application/json":JSON.parse},l(S.prototype,f.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new h;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(mn,mn.exports);var Pi=mn.exports;function Ei(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ti(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Ei)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ai(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Pi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ci(e,t,n){var r=Pi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ti.call(this,r,t,n)}function ki(e,t,n){var r=Pi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ti.call(this,r,t,n)}function Ni(e,t,n,r){var o=Pi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ti.call(this,o,n,r)}function Mi(e,t,n,r){var o=Pi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ti.call(this,o,n,r)}function ji(e,t,n){var r=Pi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ti.call(this,r,t,n)}function Ri(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ui,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Ri,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=Ri(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ii=(Ui=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ui.supportsFile="undefined"!=typeof File,Ui.supportsBlob="undefined"!=typeof Blob,Ui.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ui.supportsBuffer=!1,Ui.supportsStream=!1,Ui.supportsString=!0,Ui.supportsEncryptFile=!0,Ui.supportsFileUri=!1,Ui),Di=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:b(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Fi=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Li.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Li.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Ki)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Li.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Li=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Ki(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Ki(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Ki=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Li.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Li.SENTINEL.length+1+Li.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Li.SENTINEL)),t[e+=Li.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Li.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Bi(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Hi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new dn({del:ji,get:ki,post:Ni,patch:Mi,sendBeacon:Bi,getfile:Ci,postfile:Ai}),t.cbor=new gn((function(e){return yn(f.decode(e))}),m),t.PubNubFile=Ii,t.cryptography=new xi,t.initCryptoModule=function(e){return new Gi({default:new Di({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Fi({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Gi,n}(hn);return Hi})); diff --git a/lib/core/components/eventEmitter.js b/lib/core/components/eventEmitter.js new file mode 100644 index 000000000..898c0c7e6 --- /dev/null +++ b/lib/core/components/eventEmitter.js @@ -0,0 +1,214 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var EventEmitter = /** @class */ (function () { + function EventEmitter(_a) { + var modules = _a.modules, listenerManager = _a.listenerManager, getFileUrl = _a.getFileUrl; + this.modules = modules; + this.listenerManager = listenerManager; + this.getFileUrl = getFileUrl; + if (modules.cryptoModule) + this._decoder = new TextDecoder(); + } + EventEmitter.prototype.emitEvent = function (e) { + var channel = e.channel, publishMetaData = e.publishMetaData; + var subscriptionMatch = e.subscriptionMatch; + if (channel === subscriptionMatch) { + subscriptionMatch = null; + } + if (e.channel.endsWith('-pnpres')) { + var announce = {}; + announce.channel = null; + announce.subscription = null; + if (channel) { + announce.channel = channel.substring(0, channel.lastIndexOf('-pnpres')); + } + if (subscriptionMatch) { + announce.subscription = subscriptionMatch.substring(0, subscriptionMatch.lastIndexOf('-pnpres')); + } + announce.action = e.payload.action; + announce.state = e.payload.data; + announce.timetoken = publishMetaData.publishTimetoken; + announce.occupancy = e.payload.occupancy; + announce.uuid = e.payload.uuid; + announce.timestamp = e.payload.timestamp; + if (e.payload.join) { + announce.join = e.payload.join; + } + if (e.payload.leave) { + announce.leave = e.payload.leave; + } + if (e.payload.timeout) { + announce.timeout = e.payload.timeout; + } + this.listenerManager.announcePresence(announce); + } + else if (e.messageType === 1) { + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + announce.message = e.payload; + this.listenerManager.announceSignal(announce); + } + else if (e.messageType === 2) { + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + announce.message = { + event: e.payload.event, + type: e.payload.type, + data: e.payload.data, + }; + this.listenerManager.announceObjects(announce); + if (e.payload.type === 'uuid') { + var eventData = this._renameChannelField(announce); + this.listenerManager.announceUser(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), type: 'user' }) })); + } + else if (message.payload.type === 'channel') { + var eventData = this._renameChannelField(announce); + this.listenerManager.announceSpace(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), type: 'space' }) })); + } + else if (message.payload.type === 'membership') { + var eventData = this._renameChannelField(announce); + var _a = eventData.message.data, user = _a.uuid, space = _a.channel, membershipData = __rest(_a, ["uuid", "channel"]); + membershipData.user = user; + membershipData.space = space; + this.listenerManager.announceMembership(__assign(__assign({}, eventData), { message: __assign(__assign({}, eventData.message), { event: this._renameEvent(eventData.message.event), data: membershipData }) })); + } + } + else if (e.messageType === 3) { + var announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + announce.data = { + messageTimetoken: e.payload.data.messageTimetoken, + actionTimetoken: e.payload.data.actionTimetoken, + type: e.payload.data.type, + uuid: e.issuingClientId, + value: e.payload.data.value, + }; + announce.event = e.payload.event; + this.listenerManager.announceMessageAction(announce); + } + else if (e.messageType === 4) { + var announce = {}; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + var msgPayload = e.payload; + if (this.modules.cryptoModule) { + var decryptedPayload = void 0; + try { + var decryptedData = this.modules.cryptoModule.decrypt(e.payload); + decryptedPayload = + decryptedData instanceof ArrayBuffer ? JSON.parse(this._decoder.decode(decryptedData)) : decryptedData; + } + catch (e) { + decryptedPayload = null; + announce.error = "Error while decrypting message content: ".concat(e.message); + } + if (decryptedPayload !== null) { + msgPayload = decryptedPayload; + } + } + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + announce.message = msgPayload.message; + announce.file = { + id: msgPayload.file.id, + name: msgPayload.file.name, + url: this.getFileUrl({ + id: msgPayload.file.id, + name: msgPayload.file.name, + channel: channel, + }), + }; + this.listenerManager.announceFile(announce); + } + else { + var announce = {}; + announce.channel = null; + announce.subscription = null; + announce.channel = channel; + announce.subscription = subscriptionMatch; + announce.timetoken = publishMetaData.publishTimetoken; + announce.publisher = e.issuingClientId; + if (e.userMetadata) { + announce.userMetadata = e.userMetadata; + } + if (this.modules.cryptoModule) { + var decryptedPayload = void 0; + try { + var decryptedData = this.modules.cryptoModule.decrypt(e.payload); + decryptedPayload = + decryptedData instanceof ArrayBuffer ? JSON.parse(this._decoder.decode(decryptedData)) : decryptedData; + } + catch (e) { + decryptedPayload = null; + announce.error = "Error while decrypting message content: ".concat(e.message); + } + if (decryptedPayload != null) { + announce.message = decryptedPayload; + } + else { + announce.message = e.payload; + } + } + else { + announce.message = e.payload; + } + this.listenerManager.announceMessage(announce); + } + }; + EventEmitter.prototype.emitStatus = function (s) { + }; + EventEmitter.prototype._renameEvent = function (e) { + return e === 'set' ? 'updated' : 'removed'; + }; + EventEmitter.prototype._renameChannelField = function (announce) { + var channel = announce.channel, eventData = __rest(announce, ["channel"]); + eventData.spaceId = channel; + return eventData; + }; + return EventEmitter; +}()); +exports.default = EventEmitter; diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index 9083aa242..b87afee9e 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -143,8 +143,8 @@ var uuid_1 = __importDefault(require("./components/uuid")); var event_engine_1 = require("../event-engine"); var presence_1 = require("../event-engine/presence/presence"); var retryPolicy_1 = require("../event-engine/core/retryPolicy"); +var eventEmitter_1 = __importDefault(require("./components/eventEmitter")); var default_1 = /** @class */ (function () { - // function default_1(setup) { var _this = this; var networking = setup.networking, cbor = setup.cbor; @@ -199,6 +199,11 @@ var default_1 = /** @class */ (function () { this.handshake = endpoint_1.default.bind(this, modules, handshake_1.default); this.receiveMessages = endpoint_1.default.bind(this, modules, receiveMessages_1.default); if (config.enableEventEngine === true) { + this._eventEmitter = new eventEmitter_1.default({ + modules: modules, + listenerManager: this._listenerManager, + getFileUrl: function (params) { return (0, get_file_url_1.default)(modules, params); }, + }); if (config.maintainPresenceState) { this.presenceState = {}; this.setState = function (args) { @@ -222,6 +227,9 @@ var default_1 = /** @class */ (function () { retryDelay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, config: modules.config, presenceState: this.presenceState, + emitStatus: function (status) { + listenerManager.announceStatus(status); + }, }); this.presenceEventEngine = presenceEventEngine; this.join = this.presenceEventEngine.join.bind(presenceEventEngine); @@ -242,7 +250,7 @@ var default_1 = /** @class */ (function () { try { for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { var event_1 = events_1_1.value; - listenerManager.announceMessage(event_1); + _this._eventEmitter.emitEvent(event_1); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } diff --git a/lib/event-engine/dispatcher.js b/lib/event-engine/dispatcher.js index 767cc447e..477d06484 100644 --- a/lib/event-engine/dispatcher.js +++ b/lib/event-engine/dispatcher.js @@ -103,9 +103,11 @@ var EventEngineDispatcher = /** @class */ (function (_super) { })]; case 2: result = _b.sent(); + console.log("handshake response = ".concat(JSON.stringify(result))); return [2 /*return*/, engine.transition(events.handshakingSuccess(result))]; case 3: e_1 = _b.sent(); + console.log('at effect, received error = ', e_1, '\n', "".concat(e_1)); if (e_1 instanceof Error && e_1.message === 'Aborted') { return [2 /*return*/]; } diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index 07bde0b2b..1e8688ebe 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -34,4 +34,4 @@ exports.reconnectingSuccess = (0, core_1.createEvent)('RECEIVE_RECONNECT_SUCCESS exports.reconnectingFailure = (0, core_1.createEvent)('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); exports.reconnectingGiveup = (0, core_1.createEvent)('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); exports.reconnectingRetry = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); -exports.unsubscribeAll = (0, core_1.createEvent)('UNSUBSCRIBE_ALL', function () { }); +exports.unsubscribeAll = (0, core_1.createEvent)('UNSUBSCRIBE_ALL', function () { return ({}); }); diff --git a/lib/event-engine/presence/dispatcher.js b/lib/event-engine/presence/dispatcher.js index e08ef3dbd..49704b161 100644 --- a/lib/event-engine/presence/dispatcher.js +++ b/lib/event-engine/presence/dispatcher.js @@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -73,10 +84,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.PresenceEventEngineDispatcher = void 0; var endpoint_1 = require("../../core/components/endpoint"); var core_1 = require("../core"); +var operations_1 = __importDefault(require("../../core/constants/operations")); var effects = __importStar(require("./effects")); var events = __importStar(require("./events")); var PresenceEventEngineDispatcher = /** @class */ (function (_super) { @@ -98,7 +113,8 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { })]; case 1: result = _b.sent(); - engine.transition(events.heartbeatSuccess()); + console.log('heartbeat Success: result = ', result, '\n\n', JSON.stringify(result)); + engine.transition(events.heartbeatSuccess(200)); return [3 /*break*/, 3]; case 2: e_1 = _b.sent(); @@ -176,8 +192,7 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { })]; case 3: result = _b.sent(); - console.log("after hb call"); - return [2 /*return*/, engine.transition(events.heartbeatSuccess())]; + return [2 /*return*/, engine.transition(events.heartbeatSuccess(200))]; case 4: e_3 = _b.sent(); if (e_3 instanceof Error && e_3.message === 'Aborted') { @@ -194,6 +209,23 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { }); }); })); + _this.on(effects.emitStatus.type, (0, core_1.asyncHandler)(function (payload, _, _a) { + var emitStatus = _a.emitStatus, config = _a.config; + return __awaiter(_this, void 0, void 0, function () { + var _b; + return __generator(this, function (_c) { + if (config.announceFailedHeartbeats && ((_b = payload === null || payload === void 0 ? void 0 : payload.status) === null || _b === void 0 ? void 0 : _b.error) === true) { + console.log('failed => payload.status :', payload.status); + emitStatus(payload.status); + } + else if (config.announceSuccessfulHeartbeats && payload.statusCode === 200) { + console.log('need to announce... received event.payload = ', payload); + emitStatus(__assign(__assign({}, payload), { operation: operations_1.default.PNHeartbeatOperation, error: false })); + } + return [2 /*return*/]; + }); + }); + })); return _this; } return PresenceEventEngineDispatcher; diff --git a/lib/event-engine/presence/effects.js b/lib/event-engine/presence/effects.js index a17d3da99..3e6dd2887 100644 --- a/lib/event-engine/presence/effects.js +++ b/lib/event-engine/presence/effects.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.delayedHeartbeat = exports.wait = exports.leave = exports.heartbeat = void 0; +exports.delayedHeartbeat = exports.wait = exports.emitStatus = exports.leave = exports.heartbeat = void 0; var core_1 = require("../core"); exports.heartbeat = (0, core_1.createEffect)('HEARTBEAT', function (channels, groups) { return ({ channels: channels, @@ -10,5 +10,6 @@ exports.leave = (0, core_1.createEffect)('LEAVE', function (channels, groups) { channels: channels, groups: groups, }); }); +exports.emitStatus = (0, core_1.createEffect)('EMIT_STATUS', function (status) { return status; }); exports.wait = (0, core_1.createManagedEffect)('WAIT', function () { return ({}); }); exports.delayedHeartbeat = (0, core_1.createManagedEffect)('DELAYED_HEARTBEAT', function (context) { return context; }); diff --git a/lib/event-engine/presence/events.js b/lib/event-engine/presence/events.js index 1e07cd196..cca3e9a06 100644 --- a/lib/event-engine/presence/events.js +++ b/lib/event-engine/presence/events.js @@ -13,7 +13,7 @@ exports.left = (0, core_1.createEvent)('LEFT', function (channels, groups) { ret groups: groups, }); }); exports.leftAll = (0, core_1.createEvent)('LEFT_ALL', function () { return ({}); }); -exports.heartbeatSuccess = (0, core_1.createEvent)('HEARTBEAT_SUCCESS', function () { return ({}); }); +exports.heartbeatSuccess = (0, core_1.createEvent)('HEARTBEAT_SUCCESS', function (statusCode) { return ({ statusCode: statusCode }); }); exports.heartbeatFailure = (0, core_1.createEvent)('HEARTBEAT_FAILURE', function (error) { return error; }); exports.heartbeatGiveup = (0, core_1.createEvent)('HEARTBEAT_GIVEUP', function () { return ({}); }); exports.timesUp = (0, core_1.createEvent)('TIMES_UP', function () { return ({}); }); diff --git a/lib/event-engine/presence/states/heartbeating.js b/lib/event-engine/presence/states/heartbeating.js index 15af51c80..176fb7663 100644 --- a/lib/event-engine/presence/states/heartbeating.js +++ b/lib/event-engine/presence/states/heartbeating.js @@ -46,11 +46,11 @@ var heartbeat_stopped_1 = require("./heartbeat_stopped"); var heartbeat_inactive_1 = require("./heartbeat_inactive"); exports.HeartbeatingState = new state_1.State('HEARTBEATING'); exports.HeartbeatingState.onEnter(function (context) { return (0, effects_1.heartbeat)(context.channels, context.groups); }); -exports.HeartbeatingState.on(events_1.heartbeatSuccess.type, function (context, _) { +exports.HeartbeatingState.on(events_1.heartbeatSuccess.type, function (context, event) { return heartbeat_cooldown_1.HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups, - }); + }, [(0, effects_1.emitStatus)(event.payload)]); }); exports.HeartbeatingState.on(events_1.joined.type, function (context, event) { return exports.HeartbeatingState.with({ @@ -65,7 +65,7 @@ exports.HeartbeatingState.on(events_1.left.type, function (context, event) { }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); }); exports.HeartbeatingState.on(events_1.heartbeatFailure.type, function (context, event) { - return heartbeat_reconnecting_1.HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); + return heartbeat_reconnecting_1.HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload }), [(0, effects_1.emitStatus)(event.payload)]); }); exports.HeartbeatingState.on(events_1.disconnect.type, function (context) { return heartbeat_stopped_1.HeartbeatStoppedState.with({ diff --git a/lib/node/index.js b/lib/node/index.js index 69ae47a7a..7f463e5fa 100644 --- a/lib/node/index.js +++ b/lib/node/index.js @@ -31,7 +31,6 @@ var nodeCryptoModule_1 = require("../crypto/modules/NodeCryptoModule/nodeCryptoM module.exports = (_a = /** @class */ (function (_super) { __extends(class_1, _super); function class_1(setup) { - var _this = this; setup.cbor = new common_1.default(function (buffer) { return cbor_sync_1.default.decode(Buffer.from(buffer)); }, base64_codec_1.decode); setup.networking = new networking_1.default({ keepAlive: node_1.keepAlive, @@ -58,8 +57,7 @@ module.exports = (_a = /** @class */ (function (_super) { if (!('ssl' in setup)) { setup.ssl = true; } - _this = _super.call(this, setup) || this; - return _this; + return _super.call(this, setup) || this; } return class_1; }(pubnub_common_1.default)), diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index ff07a683b..9ada6649e 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -369,6 +369,9 @@ export default class { retryDelay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), config: modules.config, presenceState: this.presenceState, + emitStatus: (status) => { + listenerManager.announceStatus(status); + }, }); this.presenceEventEngine = presenceEventEngine; this.join = this.presenceEventEngine.join.bind(presenceEventEngine); From 0678212df799663603cc78d6989cbc688fca0b61 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 9 Jan 2024 14:48:11 +0530 Subject: [PATCH 35/63] lint --- src/event-engine/dispatcher.ts | 2 +- src/event-engine/presence/effects.ts | 4 +++- src/event-engine/presence/events.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index c948b3b29..40f61d684 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -77,7 +77,7 @@ export class EventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, _, { emitEvents }) => { if (payload.length > 0) { emitEvents(payload); } diff --git a/src/event-engine/presence/effects.ts b/src/event-engine/presence/effects.ts index b5317818f..e60579f5f 100644 --- a/src/event-engine/presence/effects.ts +++ b/src/event-engine/presence/effects.ts @@ -20,4 +20,6 @@ export const delayedHeartbeat = createManagedEffect( (context: HeartbeatReconnectingStateContext) => context, ); -export type Effects = MapOf; +export type Effects = MapOf< + typeof heartbeat | typeof leave | typeof emitStatus | typeof wait | typeof delayedHeartbeat +>; diff --git a/src/event-engine/presence/events.ts b/src/event-engine/presence/events.ts index 3e964c4af..d25642967 100644 --- a/src/event-engine/presence/events.ts +++ b/src/event-engine/presence/events.ts @@ -16,7 +16,7 @@ export const left = createEvent('LEFT', (channels: string[], groups: string[]) = export const leftAll = createEvent('LEFT_ALL', () => ({})); -export const heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', (statusCode: number) => ({ statusCode})); +export const heartbeatSuccess = createEvent('HEARTBEAT_SUCCESS', (statusCode: number) => ({ statusCode })); export const heartbeatFailure = createEvent('HEARTBEAT_FAILURE', (error: PubNubError) => error); From 1c35fe9cb69695af0dbed89a0d70468f171f8d78 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:22:43 +0530 Subject: [PATCH 36/63] event engine: naming, missing transitions, handling `reconnect` and `restore` all applicable states, removed old definitions for events --- src/event-engine/states/handshake_failed.ts | 44 +++++++++++++++ src/event-engine/states/handshake_failure.ts | 25 --------- .../states/handshake_reconnecting.ts | 56 +++++++++++-------- src/event-engine/states/handshake_stopped.ts | 31 +++++++++- src/event-engine/states/handshaking.ts | 39 ++++++++----- src/event-engine/states/receive_failed.ts | 45 +++++++++++++++ src/event-engine/states/receive_failure.ts | 53 ------------------ .../states/receive_reconnecting.ts | 32 +++++------ src/event-engine/states/receive_stopped.ts | 18 ++++-- src/event-engine/states/unsubscribed.ts | 14 +++-- 10 files changed, 211 insertions(+), 146 deletions(-) create mode 100644 src/event-engine/states/handshake_failed.ts delete mode 100644 src/event-engine/states/handshake_failure.ts create mode 100644 src/event-engine/states/receive_failed.ts delete mode 100644 src/event-engine/states/receive_failure.ts diff --git a/src/event-engine/states/handshake_failed.ts b/src/event-engine/states/handshake_failed.ts new file mode 100644 index 000000000..2fbaf177c --- /dev/null +++ b/src/event-engine/states/handshake_failed.ts @@ -0,0 +1,44 @@ +import { State } from '../core/state'; +import { Effects } from '../effects'; +import { Events, reconnect, restore, subscriptionChange, unsubscribeAll } from '../events'; +import { PubNubError } from '../../core/components/endpoint'; +import { HandshakingState } from './handshaking'; +import { UnsubscribedState } from './unsubscribed'; + +export type HandshakeFailedStateContext = { + channels: string[]; + groups: string[]; + timetoken?: string; + + reason: PubNubError; +}; + +export const HandshakeFailedState = new State('HANDSHAKE_FAILED'); + +HandshakeFailedState.on(subscriptionChange.type, (_, event) => { + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); +}); + +HandshakeFailedState.on(reconnect.type, (context, event) => + HandshakingState.with({ + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: event.payload?.timetoken ?? context.timetoken ?? '0', + region: event.payload?.region ?? 0, + }, + }), +); + +HandshakeFailedState.on(restore.type, (_, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: event.payload?.region ?? 0, + }, + }), +); + +HandshakeFailedState.on(unsubscribeAll.type, (_) => UnsubscribedState.with()); diff --git a/src/event-engine/states/handshake_failure.ts b/src/event-engine/states/handshake_failure.ts deleted file mode 100644 index 0cb9a3069..000000000 --- a/src/event-engine/states/handshake_failure.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { State } from '../core/state'; -import { Effects } from '../effects'; -import { disconnect, Events, reconnect } from '../events'; -import { PubNubError } from '../../core/components/endpoint'; -import { HandshakeReconnectingState } from './handshake_reconnecting'; -import { HandshakeStoppedState } from './handshake_stopped'; -import { HandshakingState } from './handshaking'; - -export type HandshakeFailureStateContext = { - channels: string[]; - groups: string[]; - - reason: PubNubError; -}; - -export const HandshakeFailureState = new State('HANDSHAKE_FAILURE'); - -HandshakeFailureState.on(disconnect.type, (context) => - HandshakeStoppedState.with({ - channels: context.channels, - groups: context.groups, - }), -); - -HandshakeFailureState.on(reconnect.type, (context) => HandshakingState.with({ ...context })); diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index efc7450f1..f8ac98917 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -1,17 +1,17 @@ import { PubNubError } from '../../core/components/endpoint'; import { State } from '../core/state'; -import { Effects, emitEvents, emitStatus, handshakeReconnect, reconnect } from '../effects'; +import { Effects, emitStatus, handshakeReconnect } from '../effects'; import { disconnect, Events, - handshakingReconnectingFailure, - handshakingReconnectingGiveup, - handshakingReconnectingSuccess, + handshakeReconnectFailure, + handshakeReconnectGiveup, + handshakeReconnectSuccess, restore, subscriptionChange, unsubscribeAll, } from '../events'; -import { HandshakeFailureState } from './handshake_failure'; +import { HandshakeFailedState } from './handshake_failed'; import { HandshakeStoppedState } from './handshake_stopped'; import { HandshakingState } from './handshaking'; import { ReceivingState } from './receiving'; @@ -34,8 +34,11 @@ export const HandshakeReconnectingState = new State handshakeReconnect(context)); HandshakeReconnectingState.onExit(() => handshakeReconnect.cancel); -HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, (context, event) => { - const cursor = context.timetoken ? { timetoken: context.timetoken, region: 1 } : event.payload.cursor; +HandshakeReconnectingState.on(handshakeReconnectSuccess.type, (context, event) => { + const cursor = { + timetoken: context?.timetoken ?? event.payload.cursor.timetoken, + region: event.payload.cursor.region, + }; return ReceivingState.with( { channels: context.channels, @@ -46,29 +49,31 @@ HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, (context, eve ); }); -HandshakeReconnectingState.on(handshakingReconnectingFailure.type, (context, event) => +HandshakeReconnectingState.on(handshakeReconnectFailure.type, (context, event) => HandshakeReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), ); -HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, (context) => - HandshakeFailureState.with( +HandshakeReconnectingState.on(handshakeReconnectGiveup.type, (context, event) => + HandshakeFailedState.with( { groups: context.groups, channels: context.channels, - reason: context.reason, + timetoken: context.timetoken, + reason: event.payload, }, - [emitStatus({ category: categoryConstants.PNConnectionErrorCategory })], + [emitStatus({ category: categoryConstants.PNConnectionErrorCategory, error: event.payload?.message })], ), ); HandshakeReconnectingState.on(disconnect.type, (context) => - HandshakeStoppedState.with( - { - channels: context.channels, - groups: context.groups, - }, - [emitStatus({ category: categoryConstants.PNDisconnectedCategory })], - ), + HandshakeStoppedState.with({ + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: context.timetoken ?? '0', + region: 0 + } + }), ); HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => @@ -76,9 +81,14 @@ HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => ); HandshakeReconnectingState.on(restore.type, (_, event) => - HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: event.payload?.region ?? 0, + }, + }), ); -HandshakeReconnectingState.on(unsubscribeAll.type, (_) => - UnsubscribedState.with(undefined, [emitStatus({ category: categoryConstants.PNDisconnectedCategory })]), -); +HandshakeReconnectingState.on(unsubscribeAll.type, (_) => UnsubscribedState.with(undefined)); diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index f414b7f06..344721395 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -1,20 +1,45 @@ +import { Cursor } from '../../models/Cursor'; import { State } from '../core/state'; import { Effects } from '../effects'; -import { Events, reconnect, subscriptionChange } from '../events'; +import { Events, reconnect, restore, subscriptionChange, unsubscribeAll } from '../events'; import { HandshakingState } from './handshaking'; +import { UnsubscribedState } from './unsubscribed'; type HandshakeStoppedStateContext = { channels: string[]; groups: string[]; + cursor?: Cursor; }; export const HandshakeStoppedState = new State('HANDSHAKE_STOPPED'); -HandshakeStoppedState.on(subscriptionChange.type, (_, event) => +HandshakeStoppedState.on(subscriptionChange.type, (context, event) => + HandshakeStoppedState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor + }), +); + +HandshakeStoppedState.on(reconnect.type, (context, event) => HandshakingState.with({ + ...context, + cursor: { + timetoken: event.payload?.timetoken ?? context.cursor?.timetoken ?? '0', + region: event.payload?.region ?? 0, + }, + }), +); + +HandshakeStoppedState.on(restore.type, (_, event) => + HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: event.payload?.region ?? 0, + }, }), ); -HandshakeStoppedState.on(reconnect.type, (context) => HandshakingState.with({ ...context })); +HandshakeStoppedState.on(unsubscribeAll.type, (_) => UnsubscribedState.with()); diff --git a/src/event-engine/states/handshaking.ts b/src/event-engine/states/handshaking.ts index 68b0b733e..accfe6d88 100644 --- a/src/event-engine/states/handshaking.ts +++ b/src/event-engine/states/handshaking.ts @@ -4,21 +4,23 @@ import { disconnect, restore, Events, - handshakingFailure, - handshakingSuccess, + handshakeFailure, + handshakeSuccess, subscriptionChange, unsubscribeAll, + reconnect, } from '../events'; import { HandshakeReconnectingState } from './handshake_reconnecting'; import { HandshakeStoppedState } from './handshake_stopped'; import { ReceivingState } from './receiving'; import { UnsubscribedState } from './unsubscribed'; import categoryConstants from '../../core/constants/categories'; +import { Cursor } from '../../models/Cursor'; export type HandshakingStateContext = { channels: string[]; groups: string[]; - timetoken?: string; + cursor?: Cursor; }; export const HandshakingState = new State('HANDSHAKING'); @@ -34,27 +36,33 @@ HandshakingState.on(subscriptionChange.type, (context, event) => { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); -HandshakingState.on(handshakingSuccess.type, (context, event) => +HandshakingState.on(handshakeSuccess.type, (context, event) => ReceivingState.with( { channels: context.channels, groups: context.groups, cursor: { - timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + timetoken: context.cursor?.timetoken ?? event.payload.timetoken, region: event.payload.region, }, }, - [emitStatus({ category: categoryConstants.PNConnectedCategory })], + [ + emitStatus({ + category: categoryConstants.PNConnectedCategory, + }), + ], ), ); -HandshakingState.on(handshakingFailure.type, (context, event) => - HandshakeReconnectingState.with({ - ...context, +HandshakingState.on(handshakeFailure.type, (context, event) => { + return HandshakeReconnectingState.with({ + channels: context.channels, + groups: context.groups, + timetoken: context.cursor?.timetoken, attempts: 0, reason: event.payload, - }), -); + }); +}); HandshakingState.on(disconnect.type, (context) => HandshakeStoppedState.with({ @@ -63,12 +71,15 @@ HandshakingState.on(disconnect.type, (context) => }), ); -HandshakingState.on(unsubscribeAll.type, (_) => UnsubscribedState.with()); - HandshakingState.on(restore.type, (_, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, + cursor: { + timetoken: event.payload.timetoken, + region: event.payload?.region ?? 0, + }, }), ); + +HandshakingState.on(unsubscribeAll.type, (_) => UnsubscribedState.with()); diff --git a/src/event-engine/states/receive_failed.ts b/src/event-engine/states/receive_failed.ts new file mode 100644 index 000000000..a1bdd4414 --- /dev/null +++ b/src/event-engine/states/receive_failed.ts @@ -0,0 +1,45 @@ +import { State } from '../core/state'; +import { Cursor } from '../../models/Cursor'; +import { Effects } from '../effects'; +import { Events, reconnect, restore, subscriptionChange, unsubscribeAll } from '../events'; +import { PubNubError } from '../../core/components/endpoint'; +import { HandshakingState } from './handshaking'; +import { UnsubscribedState } from './unsubscribed'; + +export type ReceiveFailedStateContext = { + channels: string[]; + groups: string[]; + cursor: Cursor; + + reason: PubNubError; +}; + +export const ReceiveFailedState = new State('RECEIVE_FAILED'); + +ReceiveFailedState.on(reconnect.type, (context, event) => + HandshakingState.with({ + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: event.payload?.timetoken ?? '0', + region: event.payload?.region ?? 0, + }, + }), +); + +ReceiveFailedState.on(subscriptionChange.type, (_, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + }), +); + +ReceiveFailedState.on(restore.type, (_, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { timetoken: event.payload.timetoken, region: event.payload?.region ?? 0 }, + }), +); + +ReceiveFailedState.on(unsubscribeAll.type, (_) => UnsubscribedState.with(undefined)); diff --git a/src/event-engine/states/receive_failure.ts b/src/event-engine/states/receive_failure.ts deleted file mode 100644 index 455966d1d..000000000 --- a/src/event-engine/states/receive_failure.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { State } from '../core/state'; -import { Cursor } from '../../models/Cursor'; -import { Effects, emitStatus } from '../effects'; -import { disconnect, Events, reconnectingRetry, restore, subscriptionChange, unsubscribeAll } from '../events'; -import { PubNubError } from '../../core/components/endpoint'; -import { HandshakingState } from './handshaking'; -import { ReceiveStoppedState } from './receive_stopped'; -import categoryConstants from '../../core/constants/categories'; -import { UnsubscribedState } from './unsubscribed'; - -export type ReceiveFailureStateContext = { - channels: string[]; - groups: string[]; - cursor: Cursor; - - reason: PubNubError; -}; - -export const ReceiveFailureState = new State('RECEIVE_FAILED'); - -ReceiveFailureState.on(reconnectingRetry.type, (context) => - HandshakingState.with({ - channels: context.channels, - groups: context.groups, - timetoken: context.cursor.timetoken, - }), -); - -ReceiveFailureState.on(disconnect.type, (context) => - ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, - cursor: context.cursor, - }), -); - -ReceiveFailureState.on(subscriptionChange.type, (_, event) => - HandshakingState.with({ - channels: event.payload.channels, - groups: event.payload.groups, - timetoken: event.payload.timetoken, - }), -); - -ReceiveFailureState.on(restore.type, (_, event) => - HandshakingState.with({ - channels: event.payload.channels, - groups: event.payload.groups, - timetoken: event.payload.timetoken, - }), -); - -ReceiveFailureState.on(unsubscribeAll.type, (_) => UnsubscribedState.with(undefined)); diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index 47c379fd0..573ddf33a 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -1,19 +1,19 @@ import { PubNubError } from '../../core/components/endpoint'; import { Cursor } from '../../models/Cursor'; import { State } from '../core/state'; -import { Effects, emitEvents, reconnect, emitStatus } from '../effects'; +import { Effects, emitMessages, receiveReconnect, emitStatus } from '../effects'; import { disconnect, Events, - reconnectingFailure, - reconnectingGiveup, - reconnectingSuccess, + receiveReconnectFailure, + receiveReconnectGiveup, + receiveReconnectSuccess, restore, subscriptionChange, unsubscribeAll, } from '../events'; import { ReceivingState } from './receiving'; -import { ReceiveFailureState } from './receive_failure'; +import { ReceiveFailedState } from './receive_failed'; import { ReceiveStoppedState } from './receive_stopped'; import { UnsubscribedState } from './unsubscribed'; import categoryConstants from '../../core/constants/categories'; @@ -31,33 +31,33 @@ export const ReceiveReconnectingState = new State reconnect(context)); -ReceiveReconnectingState.onExit(() => reconnect.cancel); +ReceiveReconnectingState.onEnter((context) => receiveReconnect(context)); +ReceiveReconnectingState.onExit(() => receiveReconnect.cancel); -ReceiveReconnectingState.on(reconnectingSuccess.type, (context, event) => +ReceiveReconnectingState.on(receiveReconnectSuccess.type, (context, event) => ReceivingState.with( { channels: context.channels, groups: context.groups, cursor: event.payload.cursor, }, - [emitEvents(event.payload.events)], + [emitMessages(event.payload.events)], ), ); -ReceiveReconnectingState.on(reconnectingFailure.type, (context, event) => +ReceiveReconnectingState.on(receiveReconnectFailure.type, (context, event) => ReceiveReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), ); -ReceiveReconnectingState.on(reconnectingGiveup.type, (context) => - ReceiveFailureState.with( +ReceiveReconnectingState.on(receiveReconnectGiveup.type, (context, event) => + ReceiveFailedState.with( { groups: context.groups, channels: context.channels, cursor: context.cursor, - reason: context.reason, + reason: event.payload, }, - [emitStatus({ category: categoryConstants.PNDisconnectedUnexpectedlyCategory })], + [emitStatus({ category: categoryConstants.PNDisconnectedUnexpectedlyCategory, error: event.payload?.message })], ), ); @@ -77,8 +77,8 @@ ReceiveReconnectingState.on(restore.type, (context, event) => channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken ?? context.cursor.timetoken, - region: event.payload.region ?? context.cursor.region, + timetoken: event.payload.timetoken, + region: event.payload?.region ?? context.cursor.region, }, }), ); diff --git a/src/event-engine/states/receive_stopped.ts b/src/event-engine/states/receive_stopped.ts index cbb0396a8..7879369fd 100644 --- a/src/event-engine/states/receive_stopped.ts +++ b/src/event-engine/states/receive_stopped.ts @@ -3,7 +3,6 @@ import { State } from '../core/state'; import { Effects } from '../effects'; import { Events, reconnect, restore, subscriptionChange, unsubscribeAll } from '../events'; import { HandshakingState } from './handshaking'; -import { ReceivingState } from './receiving'; import { UnsubscribedState } from './unsubscribed'; type ReceiveStoppedStateContext = { @@ -12,10 +11,10 @@ type ReceiveStoppedStateContext = { cursor: Cursor; }; -export const ReceiveStoppedState = new State('STOPPED'); +export const ReceiveStoppedState = new State('RECEIVE_STOPPED'); ReceiveStoppedState.on(subscriptionChange.type, (context, event) => - ReceivingState.with({ + ReceiveStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: context.cursor, @@ -23,17 +22,24 @@ ReceiveStoppedState.on(subscriptionChange.type, (context, event) => ); ReceiveStoppedState.on(restore.type, (context, event) => - ReceivingState.with({ + ReceiveStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor, + cursor: { + timetoken: event.payload.timetoken, + region: event.payload?.region ?? context.cursor.region + }, }), ); -ReceiveStoppedState.on(reconnect.type, (context) => +ReceiveStoppedState.on(reconnect.type, (context, event) => HandshakingState.with({ channels: context.channels, groups: context.groups, + cursor: { + timetoken: event.payload?.timetoken ?? context.cursor.timetoken, + region: event.payload?.region ?? context.cursor.region, + }, }), ); diff --git a/src/event-engine/states/unsubscribed.ts b/src/event-engine/states/unsubscribed.ts index b72e1dfe6..349037cb1 100644 --- a/src/event-engine/states/unsubscribed.ts +++ b/src/event-engine/states/unsubscribed.ts @@ -9,14 +9,16 @@ UnsubscribedState.on(subscriptionChange.type, (_, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, }), ); -UnsubscribedState.on(restore.type, (_, event) => - HandshakingState.with({ +UnsubscribedState.on(restore.type, (_, event) => { + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, - }), -); + cursor: { + timetoken: event.payload.timetoken, + region: event.payload?.region ?? 0, + }, + }); +}); From 77231468cb253bee6273a2d3afa8af422840348c Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:23:19 +0530 Subject: [PATCH 37/63] event engine: receiving state as per specifications --- src/event-engine/states/receiving.ts | 37 ++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index e3bed6e39..a16d24452 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -1,7 +1,15 @@ import { State } from '../core/state'; import { Cursor } from '../../models/Cursor'; -import { Effects, emitEvents, emitStatus, receiveEvents } from '../effects'; -import { disconnect, Events, receivingFailure, receivingSuccess, subscriptionChange, unsubscribeAll } from '../events'; +import { Effects, emitMessages, emitStatus, receiveMessages } from '../effects'; +import { + disconnect, + Events, + receiveFailure, + receiveSuccess, + restore, + subscriptionChange, + unsubscribeAll, +} from '../events'; import { UnsubscribedState } from './unsubscribed'; import { ReceiveReconnectingState } from './receive_reconnecting'; import { ReceiveStoppedState } from './receive_stopped'; @@ -15,12 +23,12 @@ export type ReceivingStateContext = { export const ReceivingState = new State('RECEIVING'); -ReceivingState.onEnter((context) => receiveEvents(context.channels, context.groups, context.cursor)); -ReceivingState.onExit(() => receiveEvents.cancel); +ReceivingState.onEnter((context) => receiveMessages(context.channels, context.groups, context.cursor)); +ReceivingState.onExit(() => receiveMessages.cancel); -ReceivingState.on(receivingSuccess.type, (context, event) => { +ReceivingState.on(receiveSuccess.type, (context, event) => { return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor }, [ - emitEvents(event.payload.events), + emitMessages(event.payload.events), ]); }); @@ -36,7 +44,22 @@ ReceivingState.on(subscriptionChange.type, (context, event) => { }); }); -ReceivingState.on(receivingFailure.type, (context, event) => { +ReceivingState.on(restore.type, (context, event) => { + if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { + return UnsubscribedState.with(undefined); + } + + return ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: event.payload?.region ?? context.cursor.region, + }, + }); +}); + +ReceivingState.on(receiveFailure.type, (context, event) => { return ReceiveReconnectingState.with({ ...context, attempts: 0, From 29343c1c607145fb697cfc2f1e510d08a8136b93 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:23:55 +0530 Subject: [PATCH 38/63] refined naming for event engine events and effects --- src/event-engine/dispatcher.ts | 64 ++++++++++++++++++-------------- src/event-engine/effects.ts | 12 +++--- src/event-engine/events.ts | 68 +++++++++++++++++----------------- src/event-engine/index.ts | 4 +- 4 files changed, 78 insertions(+), 70 deletions(-) diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index 40f61d684..ca2945cbc 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -5,7 +5,7 @@ import * as events from './events'; export type Dependencies = { handshake: any; - receiveEvents: any; + receiveMessages: any; join: any; leave: any; leaveAll: any; @@ -14,7 +14,7 @@ export type Dependencies = { delay: (milliseconds: number) => Promise; - emitEvents: (events: any[]) => void; + emitMessages: (events: any[]) => void; emitStatus: (status: any) => void; }; @@ -28,32 +28,33 @@ export class EventEngineDispatcher extends Dispatcher { + effects.receiveMessages.type, + asyncHandler(async (payload, abortSignal, { receiveMessages, config }) => { abortSignal.throwIfAborted(); try { - const result = await receiveEvents({ + const result = await receiveMessages({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, @@ -62,24 +63,24 @@ export class EventEngineDispatcher extends Dispatcher { + effects.emitMessages.type, + asyncHandler(async (payload, _, { emitMessages }) => { if (payload.length > 0) { - emitEvents(payload); + emitMessages(payload); } }), ); @@ -92,8 +93,8 @@ export class EventEngineDispatcher extends Dispatcher { + effects.receiveReconnect.type, + asyncHandler(async (payload, abortSignal, { receiveMessages, delay, config }) => { if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) { abortSignal.throwIfAborted(); @@ -102,7 +103,7 @@ export class EventEngineDispatcher extends Dispatcher ({ channels, groups, cursor }), ); -export const emitEvents = createEffect('EMIT_MESSAGES', (events: any[]) => events); +export const emitMessages = createEffect('EMIT_MESSAGES', (events: any[]) => events); export const emitStatus = createEffect('EMIT_STATUS', (status: any) => status); -export const reconnect = createManagedEffect( +export const receiveReconnect = createManagedEffect( 'RECEIVE_RECONNECT', (context: ReceiveReconnectingStateContext) => context, ); @@ -28,10 +28,10 @@ export const handshakeReconnect = createManagedEffect( ); export type Effects = MapOf< - | typeof receiveEvents + | typeof receiveMessages | typeof handshake - | typeof emitEvents - | typeof reconnect + | typeof emitMessages + | typeof receiveReconnect | typeof handshakeReconnect | typeof emitStatus >; diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 5495d06ed..70e7a1448 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -2,20 +2,14 @@ import { PubNubError } from '../core/components/endpoint'; import { Cursor } from '../models/Cursor'; import { createEvent, MapOf } from './core'; -export const subscriptionChange = createEvent( - 'SUBSCRIPTION_CHANGED', - (channels: string[], groups: string[], timetoken?: string) => ({ - channels, - groups, - timetoken, - }), -); +export const subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', (channels: string[], groups: string[]) => ({ + channels, + groups, +})); -export const disconnect = createEvent('DISCONNECT', () => ({})); -export const reconnect = createEvent('RECONNECT', () => ({})); export const restore = createEvent( 'SUBSCRIPTION_RESTORED', - (channels: string[], groups: string[], timetoken?: string, region?: number) => ({ + (channels: string[], groups: string[], timetoken: string, region?: number) => ({ channels, groups, timetoken, @@ -23,45 +17,49 @@ export const restore = createEvent( }), ); -export const handshakingSuccess = createEvent('HANDSHAKE_SUCCESS', (cursor: Cursor) => cursor); -export const handshakingFailure = createEvent('HANDSHAKE_FAILURE', (error: PubNubError) => error); +export const handshakeSuccess = createEvent('HANDSHAKE_SUCCESS', (cursor: Cursor) => cursor); +export const handshakeFailure = createEvent('HANDSHAKE_FAILURE', (error: PubNubError) => error); -export const handshakingReconnectingSuccess = createEvent('HANDSHAKE_RECONNECT_SUCCESS', (cursor: Cursor) => ({ +export const handshakeReconnectSuccess = createEvent('HANDSHAKE_RECONNECT_SUCCESS', (cursor: Cursor) => ({ cursor, })); -export const handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', (error: PubNubError) => error); -export const handshakingReconnectingGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', () => ({})); +export const handshakeReconnectFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', (error: PubNubError) => error); +export const handshakeReconnectGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', (error: PubNubError) => error); -export const receivingSuccess = createEvent('RECEIVE_SUCCESS', (cursor: Cursor, events: any[]) => ({ +export const receiveSuccess = createEvent('RECEIVE_SUCCESS', (cursor: Cursor, events: any[]) => ({ cursor, events, })); -export const receivingFailure = createEvent('RECEIVE_FAILURE', (error: PubNubError) => error); +export const receiveFailure = createEvent('RECEIVE_FAILURE', (error: PubNubError) => error); -export const reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', (cursor: Cursor, events: any[]) => ({ +export const receiveReconnectSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', (cursor: Cursor, events: any[]) => ({ cursor, events, })); -export const reconnectingFailure = createEvent('RECEIVE_RECONNECT_FAILURE', (error: PubNubError) => error); -export const reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', () => ({})); -export const reconnectingRetry = createEvent('RECONNECT', () => ({})); +export const receiveReconnectFailure = createEvent('RECEIVE_RECONNECT_FAILURE', (error: PubNubError) => error); +export const receiveReconnectGiveup = createEvent('RECEIVING_RECONNECT_GIVEUP', (error: PubNubError) => error); +export const disconnect = createEvent('DISCONNECT', () => ({})); + +export const reconnect = createEvent('RECONNECT', (timetoken?: string, region?: number) => ({ + timetoken, + region, +})); export const unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', () => ({})); export type Events = MapOf< | typeof subscriptionChange + | typeof restore + | typeof handshakeSuccess + | typeof handshakeFailure + | typeof handshakeReconnectSuccess + | typeof handshakeReconnectFailure + | typeof handshakeReconnectGiveup + | typeof receiveSuccess + | typeof receiveFailure + | typeof receiveReconnectSuccess + | typeof receiveReconnectFailure + | typeof receiveReconnectGiveup | typeof disconnect - | typeof unsubscribeAll | typeof reconnect - | typeof restore - | typeof handshakingSuccess - | typeof handshakingFailure - | typeof handshakingReconnectingSuccess - | typeof handshakingReconnectingGiveup - | typeof handshakingReconnectingFailure - | typeof receivingSuccess - | typeof receivingFailure - | typeof reconnectingSuccess - | typeof reconnectingFailure - | typeof reconnectingGiveup - | typeof reconnectingRetry + | typeof unsubscribeAll >; diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index c4dad0d09..a08996455 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -97,8 +97,8 @@ export class EventEngine { } } - reconnect() { - this.engine.transition(events.reconnect()); + reconnect({timetoken, region } : {timetoken?:string, region?: number}) { + this.engine.transition(events.reconnect(timetoken, region)); } disconnect() { From f4c7f157b0e184a6691cfb00f373c1eb8db5b41e Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:24:19 +0530 Subject: [PATCH 39/63] retryConfiguration behaviour updates --- src/event-engine/core/retryPolicy.ts | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/event-engine/core/retryPolicy.ts b/src/event-engine/core/retryPolicy.ts index 24de99a14..4d0203da9 100644 --- a/src/event-engine/core/retryPolicy.ts +++ b/src/event-engine/core/retryPolicy.ts @@ -1,16 +1,26 @@ export class RetryPolicy { + static excludedErrorCodes = [403, 429]; static LinearRetryPolicy(configuration: LinearRetryPolicyConfiguration) { return { delay: configuration.delay, maximumRetry: configuration.maximumRetry, shouldRetry(error: any, attempt: number) { - if (error?.status?.statusCode === 403) { + if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) { return false; } return this.maximumRetry > attempt; }, getDelay(_: number) { - return this.delay * 1000; + return (this.delay + Math.random()) * 1000; + }, + getGiveupReason(error: any, attempt: number) { + if (this.maximumRetry <= attempt) { + return 'retry attempts exhaused.'; + } + if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) { + return 'forbidden or too many requests.'; + } + return 'unknown error'; }, }; } @@ -29,13 +39,23 @@ export class RetryPolicy { }, getDelay(attempt: number) { - const calculatedDelay = Math.trunc(Math.pow(2, attempt)) * 1000 + Math.random() * 1000; - if (calculatedDelay > 150000) { - return 150000; + const calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; + if (calculatedDelay > this.maximumDelay) { + return this.maximumDelay; } else { return calculatedDelay; } }, + + getGiveupReason(error: any, attempt: number) { + if (this.maximumRetry <= attempt) { + return 'retry attempts exhaused.'; + } + if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) { + return 'forbidden or too many requests.'; + } + return 'unknown error'; + }, }; } } From 9a07850ce30a15fec285b9b738521c1cd85d76af Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:25:37 +0530 Subject: [PATCH 40/63] presence eventengine: removed unnecessary emitStatus events as per specifications --- src/event-engine/presence/dispatcher.ts | 16 +++++----- .../presence/states/heartbeat_cooldown.ts | 2 +- .../presence/states/heartbeat_inactive.ts | 4 +-- .../presence/states/heartbeat_reconnecting.ts | 15 ++++------ .../presence/states/heartbeat_stopped.ts | 29 +++++-------------- .../presence/states/heartbeating.ts | 24 ++++++--------- 6 files changed, 32 insertions(+), 58 deletions(-) diff --git a/src/event-engine/presence/dispatcher.ts b/src/event-engine/presence/dispatcher.ts index eeae3520c..82037da8b 100644 --- a/src/event-engine/presence/dispatcher.ts +++ b/src/event-engine/presence/dispatcher.ts @@ -22,13 +22,14 @@ export class PresenceEventEngineDispatcher extends Dispatcher { + asyncHandler(async (payload, _, { heartbeat, presenceState, config }) => { try { - const result = await heartbeat({ + const heartbeatParams: any = { channels: payload.channels, channelGroups: payload.groups, - state: presenceState, - }); + }; + if (config.maintainPresenceState) heartbeatParams.state = presenceState; + const result = await heartbeat(heartbeatParams); engine.transition(events.heartbeatSuccess(200)); } catch (e) { if (e instanceof PubNubError) { @@ -73,11 +74,12 @@ export class PresenceEventEngineDispatcher extends Dispatcher('HEARTBEATCOOLDOWN'); +export const HeartbeatCooldownState = new State('HEARTBEAT_COOLDOWN'); HeartbeatCooldownState.onEnter(() => wait()); HeartbeatCooldownState.onExit(() => wait.cancel); diff --git a/src/event-engine/presence/states/heartbeat_inactive.ts b/src/event-engine/presence/states/heartbeat_inactive.ts index b98a396c9..a095a3215 100644 --- a/src/event-engine/presence/states/heartbeat_inactive.ts +++ b/src/event-engine/presence/states/heartbeat_inactive.ts @@ -1,6 +1,6 @@ import { State } from '../../core/state'; import { Effects } from '../effects'; -import { Events, joined, left } from '../events'; +import { Events, joined } from '../events'; import { HeartbeatingState } from './heartbeating'; export const HeartbeatInactiveState = new State('HEARTBEAT_INACTIVE'); @@ -11,5 +11,3 @@ HeartbeatInactiveState.on(joined.type, (_, event) => groups: event.payload.groups, }), ); - -HeartbeatInactiveState.on(left.type, (_, event) => HeartbeatInactiveState.with()); diff --git a/src/event-engine/presence/states/heartbeat_reconnecting.ts b/src/event-engine/presence/states/heartbeat_reconnecting.ts index 99ac2a1a7..099a05e4d 100644 --- a/src/event-engine/presence/states/heartbeat_reconnecting.ts +++ b/src/event-engine/presence/states/heartbeat_reconnecting.ts @@ -60,19 +60,14 @@ HearbeatReconnectingState.on(disconnect.type, (context, _) => { }); HearbeatReconnectingState.on(heartbeatSuccess.type, (context, event) => { - return HeartbeatCooldownState.with( - { - channels: context.channels, - groups: context.groups, - }, - [emitStatus(event.payload)], - ); + return HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups, + }); }); HearbeatReconnectingState.on(heartbeatFailure.type, (context, event) => - HearbeatReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }, [ - emitStatus(event.payload), - ]), + HearbeatReconnectingState.with({ ...context, attempts: context.attempts + 1, reason: event.payload }), ); HearbeatReconnectingState.on(heartbeatGiveup.type, (context, event) => { diff --git a/src/event-engine/presence/states/heartbeat_stopped.ts b/src/event-engine/presence/states/heartbeat_stopped.ts index 02e49579a..ea8e85df0 100644 --- a/src/event-engine/presence/states/heartbeat_stopped.ts +++ b/src/event-engine/presence/states/heartbeat_stopped.ts @@ -1,6 +1,6 @@ import { State } from '../../core/state'; -import { Effects, leave } from '../effects'; -import { Events, joined, left, reconnect, leftAll, disconnect } from '../events'; +import { Effects } from '../effects'; +import { Events, joined, left, reconnect, leftAll } from '../events'; import { HeartbeatInactiveState } from './heartbeat_inactive'; import { HeartbeatingState } from './heartbeating'; @@ -19,13 +19,10 @@ HeartbeatStoppedState.on(joined.type, (context, event) => ); HeartbeatStoppedState.on(left.type, (context, event) => - HeartbeatStoppedState.with( - { - channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), - groups: context.groups.filter((group) => !event.payload.groups.includes(group)), - }, - [leave(event.payload.channels, event.payload.groups)], - ), + HeartbeatStoppedState.with({ + channels: context.channels.filter((channel) => !event.payload.channels.includes(channel)), + groups: context.groups.filter((group) => !event.payload.groups.includes(group)), + }), ); HeartbeatStoppedState.on(reconnect.type, (context, _) => @@ -35,16 +32,4 @@ HeartbeatStoppedState.on(reconnect.type, (context, _) => }), ); -HeartbeatStoppedState.on(disconnect.type, (context, _) => - HeartbeatStoppedState.with( - { - channels: context.channels, - groups: context.groups, - }, - [leave(context.channels, context.groups)], - ), -); - -HeartbeatStoppedState.on(leftAll.type, (context, _) => - HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]), -); +HeartbeatStoppedState.on(leftAll.type, (context, _) => HeartbeatInactiveState.with(undefined)); diff --git a/src/event-engine/presence/states/heartbeating.ts b/src/event-engine/presence/states/heartbeating.ts index 04ebea99f..1b45b9796 100644 --- a/src/event-engine/presence/states/heartbeating.ts +++ b/src/event-engine/presence/states/heartbeating.ts @@ -16,13 +16,10 @@ export const HeartbeatingState = new State heartbeat(context.channels, context.groups)); HeartbeatingState.on(heartbeatSuccess.type, (context, event) => { - return HeartbeatCooldownState.with( - { - channels: context.channels, - groups: context.groups, - }, - [emitStatus(event.payload)], - ); + return HeartbeatCooldownState.with({ + channels: context.channels, + groups: context.groups, + }); }); HeartbeatingState.on(joined.type, (context, event) => @@ -43,14 +40,11 @@ HeartbeatingState.on(left.type, (context, event) => { }); HeartbeatingState.on(heartbeatFailure.type, (context, event) => { - return HearbeatReconnectingState.with( - { - ...context, - attempts: 0, - reason: event.payload, - }, - [emitStatus(event.payload)], - ); + return HearbeatReconnectingState.with({ + ...context, + attempts: 0, + reason: event.payload, + }); }); HeartbeatingState.on(disconnect.type, (context) => From e03d14db2d9c0478e2577ef0fd039ef4c0f7ac85 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:26:42 +0530 Subject: [PATCH 41/63] config naming convention, eventengine initialisation updates as per new updated naming conventions --- src/core/components/config.js | 4 ++-- src/core/pubnub-common.js | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/components/config.js b/src/core/components/config.js index 5b2156019..395086a45 100644 --- a/src/core/components/config.js +++ b/src/core/components/config.js @@ -207,7 +207,7 @@ export default class { this.requestMessageCountThreshold = setup.requestMessageCountThreshold; if (setup.retryConfiguration) { - this.setRetryConfiguration(setup.retryConfiguration); + this._setRetryConfiguration(setup.retryConfiguration); } // set timeout to how long a transaction request will wait for the server (default 15 seconds) @@ -361,7 +361,7 @@ export default class { return '7.4.5'; } - setRetryConfiguration(configuration) { + _setRetryConfiguration(configuration) { if (configuration.minimumdelay < 2) { throw new Error('Minimum delay can not be set less than 2 seconds for retry'); } diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 9ada6649e..27a2c699e 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -380,14 +380,14 @@ export default class { } const eventEngine = new EventEngine({ handshake: this.handshake, - receiveEvents: this.receiveMessages, + receiveMessages: this.receiveMessages, delay: (amount) => new Promise((resolve) => setTimeout(resolve, amount)), join: this.join, leave: this.leave, leaveAll: this.leaveAll, presenceState: this.presenceState, config: modules.config, - emitEvents: (events) => { + emitMessages: (events) => { for (const event of events) { this._eventEmitter.emitEvent(event); } @@ -402,7 +402,9 @@ export default class { this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); this.reconnect = eventEngine.reconnect.bind(eventEngine); this.disconnect = eventEngine.disconnect.bind(eventEngine); + this.destroy = eventEngine.dispose.bind(eventEngine); this.eventEngine = eventEngine; + } else { const subscriptionManager = new SubscriptionManager({ timeEndpoint, @@ -770,7 +772,6 @@ export default class { this.setUserId = modules.config.setUserId.bind(modules.config); this.getFilterExpression = modules.config.getFilterExpression.bind(modules.config); this.setFilterExpression = modules.config.setFilterExpression.bind(modules.config); - // this.setCipherKey = modules.config.setCipherKey.bind(modules.config); this.setCipherKey = (key) => modules.config.setCipherKey(key, setup, modules); this.setHeartbeatInterval = modules.config.setHeartbeatInterval.bind(modules.config); From 41383dc86209a6a2dc9d360fc56d988642eb983f Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:27:16 +0530 Subject: [PATCH 42/63] updated tests --- test/contract/definitions/event-engine.ts | 17 +++++++++-------- .../contract/steps/cryptoModule/cryptoModule.ts | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test/contract/definitions/event-engine.ts b/test/contract/definitions/event-engine.ts index f64985165..34eed878f 100644 --- a/test/contract/definitions/event-engine.ts +++ b/test/contract/definitions/event-engine.ts @@ -1,7 +1,7 @@ import { after, binding, given, then, when } from 'cucumber-tsflow'; import { DemoKeyset } from '../shared/keysets'; import { PubNub, PubNubManager } from '../shared/pubnub'; -import type { MessageEvent, StatusEvent } from 'pubnub'; +import type { MessageEvent, PresenceEvent, StatusEvent } from 'pubnub'; import type { Change } from '../../../src/event-engine/core/change'; import { DataTable } from '@cucumber/cucumber'; import { expect } from 'chai'; @@ -32,6 +32,7 @@ class EventEngineSteps { private messagePromise?: Promise; private statusPromise?: Promise; + private presencePromise?: Promise; private changelog: Change[] = []; private configuration: any = {}; @@ -85,10 +86,10 @@ class EventEngineSteps { }); this.statusPromise = new Promise((resolveStatus) => { - this.messagePromise = new Promise((resolveMessage) => { + this.presencePromise = new Promise((resolvePresence) => { this.pubnub?.addListener({ - message(messageEvent) { - resolveMessage(messageEvent); + presence(presenceEvent) { + resolvePresence(presenceEvent); }, status(statusEvent) { resolveStatus(statusEvent); @@ -100,9 +101,9 @@ class EventEngineSteps { }); } - @then('I wait for getting Presence joined events') + @then('I wait for getting Presence joined events', undefined, 10000) async thenPresenceJoinEvent() { - const status = await this.messagePromise; + const status = await this.presencePromise; } @then('I wait {string} seconds') @@ -208,14 +209,14 @@ class EventEngineSteps { const timetoken = await this.pubnub?.publish({ channel: 'test', message: { content: 'Hello world!' } }); } - @then('I receive an error in my subscribe response') + @then('I receive an error in my subscribe response', undefined, 10000) async thenIReceiveError() { const status = await this.statusPromise; expect(status?.category).to.equal('PNConnectionErrorCategory'); } - @then('I receive the message in my subscribe response') + @then('I receive the message in my subscribe response', undefined, 10000) async receiveMessage() { const message = await this.messagePromise; } diff --git a/test/contract/steps/cryptoModule/cryptoModule.ts b/test/contract/steps/cryptoModule/cryptoModule.ts index c7785b85d..956aeb014 100644 --- a/test/contract/steps/cryptoModule/cryptoModule.ts +++ b/test/contract/steps/cryptoModule/cryptoModule.ts @@ -169,6 +169,7 @@ Then('Successfully decrypt an encrypted file with legacy code', async function ( fileStream.pipe(outputStream); outputStream.on('end', () => { const actualFileBuffer = fs.readFileSync(tempFilePath); + //@ts-ignore expect(actualFileBuffer).to.equalBytes(this.fileDataBuffer); fs.unlink(tempFilePath, () => {}); }); From aab7eae484d926227bd64d21cd5ff6d844e88472 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:31:19 +0530 Subject: [PATCH 43/63] dist, lib and lint fixes --- dist/web/pubnub.js | 460 +++++++++++------- dist/web/pubnub.min.js | 4 +- lib/core/components/config.js | 4 +- lib/core/components/eventEmitter.js | 2 - lib/core/pubnub-common.js | 6 +- lib/event-engine/core/retryPolicy.js | 31 +- lib/event-engine/dispatcher.js | 76 +-- lib/event-engine/effects.js | 8 +- lib/event-engine/events.js | 33 +- lib/event-engine/index.js | 5 +- lib/event-engine/presence/dispatcher.js | 33 +- .../presence/states/heartbeat_cooldown.js | 2 +- .../presence/states/heartbeat_inactive.js | 1 - .../presence/states/heartbeat_reconnecting.js | 2 +- .../presence/states/heartbeat_stopped.js | 13 +- .../presence/states/heartbeating.js | 4 +- lib/event-engine/states/handshake_failed.js | 34 ++ .../states/handshake_reconnecting.js | 43 +- lib/event-engine/states/handshake_stopped.js | 26 +- lib/event-engine/states/handshaking.js | 41 +- lib/event-engine/states/receive_failed.js | 34 ++ .../states/receive_reconnecting.js | 25 +- lib/event-engine/states/receive_stopped.js | 20 +- lib/event-engine/states/receiving.js | 24 +- lib/event-engine/states/unsubscribed.js | 7 +- src/core/pubnub-common.js | 1 - src/event-engine/index.ts | 2 +- .../states/handshake_reconnecting.ts | 4 +- src/event-engine/states/handshake_stopped.ts | 2 +- src/event-engine/states/receive_stopped.ts | 2 +- 30 files changed, 604 insertions(+), 345 deletions(-) create mode 100644 lib/event-engine/states/handshake_failed.js create mode 100644 lib/event-engine/states/receive_failed.js diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index ebeef507c..c56ee50fd 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -668,7 +668,7 @@ this.useRequestId = setup.useRequestId || false; this.requestMessageCountThreshold = setup.requestMessageCountThreshold; if (setup.retryConfiguration) { - this.setRetryConfiguration(setup.retryConfiguration); + this._setRetryConfiguration(setup.retryConfiguration); } // set timeout to how long a transaction request will wait for the server (default 15 seconds) this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000); @@ -796,7 +796,7 @@ default_1.prototype.getVersion = function () { return '7.4.5'; }; - default_1.prototype.setRetryConfiguration = function (configuration) { + default_1.prototype._setRetryConfiguration = function (configuration) { if (configuration.minimumdelay < 2) { throw new Error('Minimum delay can not be set less than 2 seconds for retry'); } @@ -7145,44 +7145,45 @@ channels: channels, groups: groups, }); }); - var receiveEvents = createManagedEffect('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); - var emitEvents = createEffect('EMIT_MESSAGES', function (events) { return events; }); + var receiveMessages = createManagedEffect('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); + var emitMessages = createEffect('EMIT_MESSAGES', function (events) { return events; }); var emitStatus$1 = createEffect('EMIT_STATUS', function (status) { return status; }); - var reconnect$2 = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); + var receiveReconnect = createManagedEffect('RECEIVE_RECONNECT', function (context) { return context; }); var handshakeReconnect = createManagedEffect('HANDSHAKE_RECONNECT', function (context) { return context; }); - var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ + var subscriptionChange = createEvent('SUBSCRIPTION_CHANGED', function (channels, groups) { return ({ channels: channels, groups: groups, - timetoken: timetoken, }); }); - var disconnect$1 = createEvent('DISCONNECT', function () { return ({}); }); - var reconnect$1 = createEvent('RECONNECT', function () { return ({}); }); var restore = createEvent('SUBSCRIPTION_RESTORED', function (channels, groups, timetoken, region) { return ({ channels: channels, groups: groups, timetoken: timetoken, region: region, }); }); - var handshakingSuccess = createEvent('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); - var handshakingFailure = createEvent('HANDSHAKE_FAILURE', function (error) { return error; }); - var handshakingReconnectingSuccess = createEvent('HANDSHAKE_RECONNECT_SUCCESS', function (cursor) { return ({ + var handshakeSuccess = createEvent('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); + var handshakeFailure = createEvent('HANDSHAKE_FAILURE', function (error) { return error; }); + var handshakeReconnectSuccess = createEvent('HANDSHAKE_RECONNECT_SUCCESS', function (cursor) { return ({ cursor: cursor, }); }); - var handshakingReconnectingFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); - var handshakingReconnectingGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', function () { return ({}); }); - var receivingSuccess = createEvent('RECEIVE_SUCCESS', function (cursor, events) { return ({ + var handshakeReconnectFailure = createEvent('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); + var handshakeReconnectGiveup = createEvent('HANDSHAKE_RECONNECT_GIVEUP', function (error) { return error; }); + var receiveSuccess = createEvent('RECEIVE_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); - var receivingFailure = createEvent('RECEIVE_FAILURE', function (error) { return error; }); - var reconnectingSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ + var receiveFailure = createEvent('RECEIVE_FAILURE', function (error) { return error; }); + var receiveReconnectSuccess = createEvent('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); - var reconnectingFailure = createEvent('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); - var reconnectingGiveup = createEvent('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); - var reconnectingRetry = createEvent('RECONNECT', function () { return ({}); }); + var receiveReconnectFailure = createEvent('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); + var receiveReconnectGiveup = createEvent('RECEIVING_RECONNECT_GIVEUP', function (error) { return error; }); + var disconnect$1 = createEvent('DISCONNECT', function () { return ({}); }); + var reconnect$1 = createEvent('RECONNECT', function (timetoken, region) { return ({ + timetoken: timetoken, + region: region, + }); }); var unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', function () { return ({}); }); var EventEngineDispatcher = /** @class */ (function (_super) { @@ -7192,7 +7193,7 @@ _this.on(handshake.type, asyncHandler(function (payload, abortSignal, _a) { var handshake = _a.handshake, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var result, e_1; + var handshakeParams, result, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -7200,25 +7201,25 @@ _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); - return [4 /*yield*/, handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - state: presenceState, - })]; + handshakeParams = { + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + filterExpression: config.filterExpression, + }; + if (config.maintainPresenceState) + handshakeParams.state = presenceState; + return [4 /*yield*/, handshake(handshakeParams)]; case 2: result = _b.sent(); - console.log("handshake response = ".concat(JSON.stringify(result))); - return [2 /*return*/, engine.transition(handshakingSuccess(result))]; + return [2 /*return*/, engine.transition(handshakeSuccess(result))]; case 3: e_1 = _b.sent(); - console.log('at effect, received error = ', e_1, '\n', "".concat(e_1)); if (e_1 instanceof Error && e_1.message === 'Aborted') { return [2 /*return*/]; } if (e_1 instanceof PubNubError) { - return [2 /*return*/, engine.transition(handshakingFailure(e_1))]; + return [2 /*return*/, engine.transition(handshakeFailure(e_1))]; } return [3 /*break*/, 4]; case 4: return [2 /*return*/]; @@ -7226,8 +7227,8 @@ }); }); })); - _this.on(receiveEvents.type, asyncHandler(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents, config = _a.config; + _this.on(receiveMessages.type, asyncHandler(function (payload, abortSignal, _a) { + var receiveMessages = _a.receiveMessages, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_1; return __generator(this, function (_b) { @@ -7237,7 +7238,7 @@ _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); - return [4 /*yield*/, receiveEvents({ + return [4 /*yield*/, receiveMessages({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, @@ -7247,7 +7248,7 @@ })]; case 2: result = _b.sent(); - engine.transition(receivingSuccess(result.metadata, result.messages)); + engine.transition(receiveSuccess(result.metadata, result.messages)); return [3 /*break*/, 4]; case 3: error_1 = _b.sent(); @@ -7255,7 +7256,7 @@ return [2 /*return*/]; } if (error_1 instanceof PubNubError && !abortSignal.aborted) { - return [2 /*return*/, engine.transition(receivingFailure(error_1))]; + return [2 /*return*/, engine.transition(receiveFailure(error_1))]; } return [3 /*break*/, 4]; case 4: return [2 /*return*/]; @@ -7263,12 +7264,12 @@ }); }); })); - _this.on(emitEvents.type, asyncHandler(function (payload, _, _a) { - var emitEvents = _a.emitEvents; + _this.on(emitMessages.type, asyncHandler(function (payload, _, _a) { + var emitMessages = _a.emitMessages; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { if (payload.length > 0) { - emitEvents(payload); + emitMessages(payload); } return [2 /*return*/]; }); @@ -7283,8 +7284,8 @@ }); }); })); - _this.on(reconnect$2.type, asyncHandler(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents, delay = _a.delay, config = _a.config; + _this.on(receiveReconnect.type, asyncHandler(function (payload, abortSignal, _a) { + var receiveMessages = _a.receiveMessages, delay = _a.delay, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_2; return __generator(this, function (_b) { @@ -7299,7 +7300,7 @@ _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, receiveEvents({ + return [4 /*yield*/, receiveMessages({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, @@ -7309,18 +7310,18 @@ })]; case 3: result = _b.sent(); - return [2 /*return*/, engine.transition(reconnectingSuccess(result.metadata, result.messages))]; + return [2 /*return*/, engine.transition(receiveReconnectSuccess(result.metadata, result.messages))]; case 4: error_2 = _b.sent(); if (error_2 instanceof Error && error_2.message === 'Aborted') { return [2 /*return*/]; } if (error_2 instanceof PubNubError) { - return [2 /*return*/, engine.transition(reconnectingFailure(error_2))]; + return [2 /*return*/, engine.transition(receiveReconnectFailure(error_2))]; } return [3 /*break*/, 5]; case 5: return [3 /*break*/, 7]; - case 6: return [2 /*return*/, engine.transition(reconnectingGiveup())]; + case 6: return [2 /*return*/, engine.transition(receiveReconnectGiveup(new PubNubError(config.retryConfiguration.getGiveupReason(payload.reason, payload.attempts))))]; case 7: return [2 /*return*/]; } }); @@ -7329,7 +7330,7 @@ _this.on(handshakeReconnect.type, asyncHandler(function (payload, abortSignal, _a) { var handshake = _a.handshake, delay = _a.delay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var result, error_3; + var handshakeParams, result, error_3; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -7342,27 +7343,29 @@ _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - state: presenceState, - })]; + handshakeParams = { + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + filterExpression: config.filterExpression, + }; + if (config.maintainPresenceState) + handshakeParams.state = presenceState; + return [4 /*yield*/, handshake(handshakeParams)]; case 3: result = _b.sent(); - return [2 /*return*/, engine.transition(handshakingReconnectingSuccess(result))]; + return [2 /*return*/, engine.transition(handshakeReconnectSuccess(result))]; case 4: error_3 = _b.sent(); if (error_3 instanceof Error && error_3.message === 'Aborted') { return [2 /*return*/]; } if (error_3 instanceof PubNubError) { - return [2 /*return*/, engine.transition(handshakingReconnectingFailure(error_3))]; + return [2 /*return*/, engine.transition(handshakeReconnectFailure(error_3))]; } return [3 /*break*/, 5]; case 5: return [3 /*break*/, 7]; - case 6: return [2 /*return*/, engine.transition(handshakingReconnectingGiveup())]; + case 6: return [2 /*return*/, engine.transition(handshakeReconnectGiveup(new PubNubError(config.retryConfiguration.getGiveupReason(payload.reason, payload.attempts))))]; case 7: return [2 /*return*/]; } }); @@ -7373,98 +7376,143 @@ return EventEngineDispatcher; }(Dispatcher)); - var HandshakeStoppedState = new State('HANDSHAKE_STOPPED'); - HandshakeStoppedState.on(subscriptionChange.type, function (_, event) { + var HandshakeFailedState = new State('HANDSHAKE_FAILED'); + HandshakeFailedState.on(subscriptionChange.type, function (_, event) { + return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + }); + HandshakeFailedState.on(reconnect$1.type, function (context, event) { + var _a, _b, _c, _d, _e; + return HandshakingState.with({ + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: (_c = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.timetoken) !== null && _c !== void 0 ? _c : '0', + region: (_e = (_d = event.payload) === null || _d === void 0 ? void 0 : _d.region) !== null && _e !== void 0 ? _e : 0, + }, + }); + }); + HandshakeFailedState.on(restore.type, function (_, event) { + var _a, _b; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, }); }); - HandshakeStoppedState.on(reconnect$1.type, function (context) { return HandshakingState.with(__assign({}, context)); }); + HandshakeFailedState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(); }); - var HandshakeFailureState = new State('HANDSHAKE_FAILURE'); - HandshakeFailureState.on(disconnect$1.type, function (context) { + var HandshakeStoppedState = new State('HANDSHAKE_STOPPED'); + HandshakeStoppedState.on(subscriptionChange.type, function (context, event) { return HandshakeStoppedState.with({ - channels: context.channels, - groups: context.groups, - }); - }); - HandshakeFailureState.on(reconnect$1.type, function (context) { return HandshakingState.with(__assign({}, context)); }); - - var ReceiveStoppedState = new State('STOPPED'); - ReceiveStoppedState.on(subscriptionChange.type, function (context, event) { - return ReceivingState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor, + cursor: context.cursor }); }); - ReceiveStoppedState.on(restore.type, function (context, event) { - return ReceivingState.with({ + HandshakeStoppedState.on(reconnect$1.type, function (context, event) { + var _a, _b, _c, _d, _e, _f; + return HandshakingState.with(__assign(__assign({}, context), { cursor: { + timetoken: (_d = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : (_c = context.cursor) === null || _c === void 0 ? void 0 : _c.timetoken) !== null && _d !== void 0 ? _d : '0', + region: (_f = (_e = event.payload) === null || _e === void 0 ? void 0 : _e.region) !== null && _f !== void 0 ? _f : 0, + } })); + }); + HandshakeStoppedState.on(restore.type, function (_, event) { + var _a, _b; + return HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, }); }); - ReceiveStoppedState.on(reconnect$1.type, function (context) { + HandshakeStoppedState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(); }); + + var ReceiveFailedState = new State('RECEIVE_FAILED'); + ReceiveFailedState.on(reconnect$1.type, function (context, event) { + var _a, _b, _c, _d; return HandshakingState.with({ channels: context.channels, groups: context.groups, + cursor: { + timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : '0', + region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : 0, + }, }); }); - ReceiveStoppedState.on(unsubscribeAll.type, function () { return UnsubscribedState.with(undefined); }); - - var ReceiveFailureState = new State('RECEIVE_FAILED'); - ReceiveFailureState.on(reconnectingRetry.type, function (context) { + ReceiveFailedState.on(subscriptionChange.type, function (_, event) { return HandshakingState.with({ - channels: context.channels, - groups: context.groups, - timetoken: context.cursor.timetoken, + channels: event.payload.channels, + groups: event.payload.groups, }); }); - ReceiveFailureState.on(disconnect$1.type, function (context) { + ReceiveFailedState.on(restore.type, function (_, event) { + var _a, _b; + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { timetoken: event.payload.timetoken, region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0 }, + }); + }); + ReceiveFailedState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(undefined); }); + + var ReceiveStoppedState = new State('RECEIVE_STOPPED'); + ReceiveStoppedState.on(subscriptionChange.type, function (context, event) { return ReceiveStoppedState.with({ - channels: context.channels, - groups: context.groups, + channels: event.payload.channels, + groups: event.payload.groups, cursor: context.cursor, }); }); - ReceiveFailureState.on(subscriptionChange.type, function (_, event) { - return HandshakingState.with({ + ReceiveStoppedState.on(restore.type, function (context, event) { + var _a, _b; + return ReceiveStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region + }, }); }); - ReceiveFailureState.on(restore.type, function (_, event) { + ReceiveStoppedState.on(reconnect$1.type, function (context, event) { + var _a, _b, _c, _d; return HandshakingState.with({ - channels: event.payload.channels, - groups: event.payload.groups, - timetoken: event.payload.timetoken, + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.cursor.timetoken, + region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : context.cursor.region, + }, }); }); - ReceiveFailureState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(undefined); }); + ReceiveStoppedState.on(unsubscribeAll.type, function () { return UnsubscribedState.with(undefined); }); var ReceiveReconnectingState = new State('RECEIVE_RECONNECTING'); - ReceiveReconnectingState.onEnter(function (context) { return reconnect$2(context); }); - ReceiveReconnectingState.onExit(function () { return reconnect$2.cancel; }); - ReceiveReconnectingState.on(reconnectingSuccess.type, function (context, event) { + ReceiveReconnectingState.onEnter(function (context) { return receiveReconnect(context); }); + ReceiveReconnectingState.onExit(function () { return receiveReconnect.cancel; }); + ReceiveReconnectingState.on(receiveReconnectSuccess.type, function (context, event) { return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor, - }, [emitEvents(event.payload.events)]); + }, [emitMessages(event.payload.events)]); }); - ReceiveReconnectingState.on(reconnectingFailure.type, function (context, event) { + ReceiveReconnectingState.on(receiveReconnectFailure.type, function (context, event) { return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); }); - ReceiveReconnectingState.on(reconnectingGiveup.type, function (context) { - return ReceiveFailureState.with({ + ReceiveReconnectingState.on(receiveReconnectGiveup.type, function (context, event) { + var _a; + return ReceiveFailedState.with({ groups: context.groups, channels: context.channels, cursor: context.cursor, - reason: context.reason, - }, [emitStatus$1({ category: categories.PNDisconnectedUnexpectedlyCategory })]); + reason: event.payload, + }, [emitStatus$1({ category: categories.PNDisconnectedUnexpectedlyCategory, error: (_a = event.payload) === null || _a === void 0 ? void 0 : _a.message })]); }); ReceiveReconnectingState.on(disconnect$1.type, function (context) { return ReceiveStoppedState.with({ @@ -7479,8 +7527,8 @@ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: (_a = event.payload.timetoken) !== null && _a !== void 0 ? _a : context.cursor.timetoken, - region: (_b = event.payload.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, }, }); }); @@ -7496,11 +7544,11 @@ }); var ReceivingState = new State('RECEIVING'); - ReceivingState.onEnter(function (context) { return receiveEvents(context.channels, context.groups, context.cursor); }); - ReceivingState.onExit(function () { return receiveEvents.cancel; }); - ReceivingState.on(receivingSuccess.type, function (context, event) { + ReceivingState.onEnter(function (context) { return receiveMessages(context.channels, context.groups, context.cursor); }); + ReceivingState.onExit(function () { return receiveMessages.cancel; }); + ReceivingState.on(receiveSuccess.type, function (context, event) { return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor }, [ - emitEvents(event.payload.events), + emitMessages(event.payload.events), ]); }); ReceivingState.on(subscriptionChange.type, function (context, event) { @@ -7513,7 +7561,21 @@ groups: event.payload.groups, }); }); - ReceivingState.on(receivingFailure.type, function (context, event) { + ReceivingState.on(restore.type, function (context, event) { + var _a, _b; + if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { + return UnsubscribedState.with(undefined); + } + return ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + }, + }); + }); + ReceivingState.on(receiveFailure.type, function (context, event) { return ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); }); ReceivingState.on(disconnect$1.type, function (context) { @@ -7530,39 +7592,56 @@ var HandshakeReconnectingState = new State('HANDSHAKE_RECONNECTING'); HandshakeReconnectingState.onEnter(function (context) { return handshakeReconnect(context); }); HandshakeReconnectingState.onExit(function () { return handshakeReconnect.cancel; }); - HandshakeReconnectingState.on(handshakingReconnectingSuccess.type, function (context, event) { - var cursor = context.timetoken ? { timetoken: context.timetoken, region: 1 } : event.payload.cursor; + HandshakeReconnectingState.on(handshakeReconnectSuccess.type, function (context, event) { + var _a; + var cursor = { + timetoken: (_a = context === null || context === void 0 ? void 0 : context.timetoken) !== null && _a !== void 0 ? _a : event.payload.cursor.timetoken, + region: event.payload.cursor.region, + }; return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: cursor, }, [emitStatus$1({ category: categories.PNConnectedCategory })]); }); - HandshakeReconnectingState.on(handshakingReconnectingFailure.type, function (context, event) { + HandshakeReconnectingState.on(handshakeReconnectFailure.type, function (context, event) { return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); }); - HandshakeReconnectingState.on(handshakingReconnectingGiveup.type, function (context) { - return HandshakeFailureState.with({ + HandshakeReconnectingState.on(handshakeReconnectGiveup.type, function (context, event) { + var _a; + return HandshakeFailedState.with({ groups: context.groups, channels: context.channels, - reason: context.reason, - }, [emitStatus$1({ category: categories.PNConnectionErrorCategory })]); + timetoken: context.timetoken, + reason: event.payload, + }, [emitStatus$1({ category: categories.PNConnectionErrorCategory, error: (_a = event.payload) === null || _a === void 0 ? void 0 : _a.message })]); }); HandshakeReconnectingState.on(disconnect$1.type, function (context) { + var _a; return HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - }, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); + cursor: { + timetoken: (_a = context.timetoken) !== null && _a !== void 0 ? _a : '0', + region: 0 + } + }); }); HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); HandshakeReconnectingState.on(restore.type, function (_, event) { - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); - }); - HandshakeReconnectingState.on(unsubscribeAll.type, function (_) { - return UnsubscribedState.with(undefined, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); + var _a, _b; + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, + }); }); + HandshakeReconnectingState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(undefined); }); var HandshakingState = new State('HANDSHAKING'); HandshakingState.onEnter(function (context) { return handshake(context.channels, context.groups); }); @@ -7573,18 +7652,30 @@ } return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); - HandshakingState.on(handshakingSuccess.type, function (context, event) { + HandshakingState.on(handshakeSuccess.type, function (context, event) { + var _a, _b; return ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: { - timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + timetoken: (_b = (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : event.payload.timetoken, region: event.payload.region, }, - }, [emitStatus$1({ category: categories.PNConnectedCategory })]); + }, [ + emitStatus$1({ + category: categories.PNConnectedCategory, + }), + ]); }); - HandshakingState.on(handshakingFailure.type, function (context, event) { - return HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); + HandshakingState.on(handshakeFailure.type, function (context, event) { + var _a; + return HandshakeReconnectingState.with({ + channels: context.channels, + groups: context.groups, + timetoken: (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken, + attempts: 0, + reason: event.payload, + }); }); HandshakingState.on(disconnect$1.type, function (context) { return HandshakeStoppedState.with({ @@ -7592,28 +7683,35 @@ groups: context.groups, }); }); - HandshakingState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(); }); HandshakingState.on(restore.type, function (_, event) { + var _a, _b; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, }); }); + HandshakingState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(); }); var UnsubscribedState = new State('UNSUBSCRIBED'); UnsubscribedState.on(subscriptionChange.type, function (_, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, }); }); UnsubscribedState.on(restore.type, function (_, event) { + var _a, _b; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, }); }); @@ -7693,8 +7791,9 @@ this.dependencies.leaveAll(); } }; - EventEngine.prototype.reconnect = function () { - this.engine.transition(reconnect$1()); + EventEngine.prototype.reconnect = function (_a) { + var timetoken = _a.timetoken, region = _a.region; + this.engine.transition(reconnect$1(timetoken, region)); }; EventEngine.prototype.disconnect = function () { this.engine.transition(disconnect$1()); @@ -7743,21 +7842,22 @@ function PresenceEventEngineDispatcher(engine, dependencies) { var _this = _super.call(this, dependencies) || this; _this.on(heartbeat.type, asyncHandler(function (payload, _, _a) { - var heartbeat = _a.heartbeat, presenceState = _a.presenceState; + var heartbeat = _a.heartbeat, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var result, e_1; + var heartbeatParams, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); - return [4 /*yield*/, heartbeat({ - channels: payload.channels, - channelGroups: payload.groups, - state: presenceState, - })]; + heartbeatParams = { + channels: payload.channels, + channelGroups: payload.groups, + }; + if (config.maintainPresenceState) + heartbeatParams.state = presenceState; + return [4 /*yield*/, heartbeat(heartbeatParams)]; case 1: - result = _b.sent(); - console.log('heartbeat Success: result = ', result, '\n\n', JSON.stringify(result)); + _b.sent(); engine.transition(heartbeatSuccess(200)); return [3 /*break*/, 3]; case 2: @@ -7815,7 +7915,7 @@ _this.on(delayedHeartbeat.type, asyncHandler(function (payload, abortSignal, _a) { var heartbeat = _a.heartbeat, retryDelay = _a.retryDelay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var e_3; + var heartbeatParams, e_3; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -7828,11 +7928,13 @@ _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, heartbeat({ - channels: payload.channels, - channelGroups: payload.groups, - state: presenceState, - })]; + heartbeatParams = { + channels: payload.channels, + channelGroups: payload.groups, + }; + if (config.maintainPresenceState) + heartbeatParams.state = presenceState; + return [4 /*yield*/, heartbeat(heartbeatParams)]; case 3: _b.sent(); return [2 /*return*/, engine.transition(heartbeatSuccess(200))]; @@ -7858,11 +7960,9 @@ var _b; return __generator(this, function (_c) { if (config.announceFailedHeartbeats && ((_b = payload === null || payload === void 0 ? void 0 : payload.status) === null || _b === void 0 ? void 0 : _b.error) === true) { - console.log('failed => payload.status :', payload.status); emitStatus(payload.status); } else if (config.announceSuccessfulHeartbeats && payload.statusCode === 200) { - console.log('need to announce... received event.payload = ', payload); emitStatus(__assign(__assign({}, payload), { operation: OPERATIONS.PNHeartbeatOperation, error: false })); } return [2 /*return*/]; @@ -7885,7 +7985,7 @@ return HeartbeatStoppedState.with({ channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), - }, [leave(event.payload.channels, event.payload.groups)]); + }); }); HeartbeatStoppedState.on(reconnect.type, function (context, _) { return HeartbeatingState.with({ @@ -7893,17 +7993,9 @@ groups: context.groups, }); }); - HeartbeatStoppedState.on(disconnect.type, function (context, _) { - return HeartbeatStoppedState.with({ - channels: context.channels, - groups: context.groups, - }, [leave(context.channels, context.groups)]); - }); - HeartbeatStoppedState.on(leftAll.type, function (context, _) { - return HeartbeatInactiveState.with(undefined, [leave(context.channels, context.groups)]); - }); + HeartbeatStoppedState.on(leftAll.type, function (context, _) { return HeartbeatInactiveState.with(undefined); }); - var HeartbeatCooldownState = new State('HEARTBEATCOOLDOWN'); + var HeartbeatCooldownState = new State('HEARTBEAT_COOLDOWN'); HeartbeatCooldownState.onEnter(function () { return wait(); }); HeartbeatCooldownState.onExit(function () { return wait.cancel; }); HeartbeatCooldownState.on(timesUp.type, function (context, _) { @@ -7984,7 +8076,7 @@ groups: context.groups, }, [leave(context.channels, context.groups)]); }); - HearbeatReconnectingState.on(heartbeatSuccess.type, function (context, _) { + HearbeatReconnectingState.on(heartbeatSuccess.type, function (context, event) { return HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups, @@ -8009,7 +8101,7 @@ return HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups, - }, [emitStatus(event.payload)]); + }); }); HeartbeatingState.on(joined.type, function (context, event) { return HeartbeatingState.with({ @@ -8024,7 +8116,7 @@ }, [leave(event.payload.channels, event.payload.groups)]); }); HeartbeatingState.on(heartbeatFailure.type, function (context, event) { - return HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload }), [emitStatus(event.payload)]); + return HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); }); HeartbeatingState.on(disconnect.type, function (context) { return HeartbeatStoppedState.with({ @@ -8043,7 +8135,6 @@ groups: event.payload.groups, }); }); - HeartbeatInactiveState.on(left.type, function (_, event) { return HeartbeatInactiveState.with(); }); var PresenceEventEngine = /** @class */ (function () { function PresenceEventEngine(dependencies) { @@ -8101,13 +8192,23 @@ maximumRetry: configuration.maximumRetry, shouldRetry: function (error, attempt) { var _a; - if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { return false; } return this.maximumRetry > attempt; }, getDelay: function (_) { - return this.delay * 1000; + return (this.delay + Math.random()) * 1000; + }, + getGiveupReason: function (error, attempt) { + var _a; + if (this.maximumRetry <= attempt) { + return 'retry attempts exhaused.'; + } + if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { + return 'forbidden or too many requests.'; + } + return 'unknown error'; }, }; }; @@ -8124,16 +8225,27 @@ return this.maximumRetry > attempt; }, getDelay: function (attempt) { - var calculatedDelay = Math.trunc(Math.pow(2, attempt)) * 1000 + Math.random() * 1000; - if (calculatedDelay > 150000) { - return 150000; + var calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; + if (calculatedDelay > this.maximumDelay) { + return this.maximumDelay; } else { return calculatedDelay; } }, + getGiveupReason: function (error, attempt) { + var _a; + if (this.maximumRetry <= attempt) { + return 'retry attempts exhaused.'; + } + if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { + return 'forbidden or too many requests.'; + } + return 'unknown error'; + }, }; }; + RetryPolicy.excludedErrorCodes = [403, 429]; return RetryPolicy; }()); @@ -8314,8 +8426,6 @@ this.listenerManager.announceMessage(announce); } }; - EventEmitter.prototype.emitStatus = function (s) { - }; EventEmitter.prototype._renameEvent = function (e) { return e === 'set' ? 'updated' : 'removed'; }; @@ -8421,14 +8531,14 @@ } var eventEngine = new EventEngine({ handshake: this.handshake, - receiveEvents: this.receiveMessages, + receiveMessages: this.receiveMessages, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, join: this.join, leave: this.leave, leaveAll: this.leaveAll, presenceState: this.presenceState, config: modules.config, - emitEvents: function (events) { + emitMessages: function (events) { var e_1, _a; try { for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { @@ -8453,6 +8563,7 @@ this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); this.reconnect = eventEngine.reconnect.bind(eventEngine); this.disconnect = eventEngine.disconnect.bind(eventEngine); + this.destroy = eventEngine.dispose.bind(eventEngine); this.eventEngine = eventEngine; } else { @@ -8789,7 +8900,6 @@ this.setUserId = modules.config.setUserId.bind(modules.config); this.getFilterExpression = modules.config.getFilterExpression.bind(modules.config); this.setFilterExpression = modules.config.setFilterExpression.bind(modules.config); - // this.setCipherKey = modules.config.setCipherKey.bind(modules.config); this.setCipherKey = function (key) { return modules.config.setCipherKey(key, setup, modules); }; this.setHeartbeatInterval = modules.config.setHeartbeatInterval.bind(modules.config); if (networking.hasModule('proxy')) { diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index f8de18c4d..308a7e60a 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return f(3,o.length),p(o);default:var h;if(Array.isArray(t))for(f(4,h=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,f,m=l(),b=m>>5,v=31&m;if(7===b)switch(v){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((f=d(v))<0&&(b<2||6=0;)S+=f,_.push(c(f));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(f);case 3:var P=[];if(f<0)for(;(f=y(b))>=0;)g(P,f);else g(P,f);return String.fromCharCode.apply(null,P);case 4:var E;if(f<0)for(E=[];!h();)E.push(e());else for(E=new Array(f),o=0;o0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return d(3,o.length),p(o);default:var f;if(Array.isArray(t))for(d(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var v=function e(){var o,d,v=l(),m=v>>5,b=31&v;if(7===m)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((d=h(b))<0&&(m<2||6=0;)S+=d,_.push(c(d));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(d);case 3:var P=[];if(d<0)for(;(d=y(m))>=0;)g(P,d);else g(P,d);return String.fromCharCode.apply(null,P);case 4:var E;if(d<0)for(E=[];!f();)E.push(e());else for(E=new Array(d),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype.setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,h=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=f,64!=l&&(o[s+1]=h),64!=p&&(o[s+2]=d)}return r}function b(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var v,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),f=2;f<=p;f++)if(!(l%f)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var h=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],f=0;64>f;f++){if(16>f)h[f]=0|e[t+f];else{var d=h[f-15],y=h[f-2];h[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+h[f-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+h[f-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+h[f],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(v=P).enc.Utf8,v.algo.HMAC=v.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],f=e[i+4],h=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],b=e[i+10],v=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,f,7,c[4]),E=t(E,P,A,T,h,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,b,17,c[10]),A=t(A,T,E,P,v,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,v,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,h,5,c[20]),E=n(E,P,A,T,b,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,f,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,h,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,v,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,f,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,b,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,h,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,b,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,f,6,c[60]),E=o(E,P,A,T,v,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(u=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),h=(h.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:h}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,f.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],f=[],h=[],d=0;256>d;d++)h[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var b=h[y],v=h[b],_=h[v],S=257*h[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*v^257*b^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,f[m]=S,y?(y=b^h[h[h[_^b]]],g^=h[h[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,f,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],f=e[t+3]^n[3],h=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[f>>>8&255]^a[255&c]^n[h++],m=r[p>>>24]^o[f>>>16&255]^i[c>>>8&255]^a[255&l]^n[h++];f=r[f>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[f>>>8&255]<<8|s[255&c])^n[h++],m=(s[p>>>24]<<24|s[f>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,f=r(u,["uuid","channel"]);f.user=l,f.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:f})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var h=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(h=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=h.message,y.file={id:h.file.id,name:h.file.name,url:o._getFileUrl({id:h.file.id,name:h.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),x={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==x.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==x.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case x.PNPublishOperation:t="pub";break;case x.PNSignalOperation:t="sig";break;case x.PNHistoryOperation:case x.PNFetchMessagesOperation:case x.PNDeleteMessagesOperation:case x.PNMessageCounts:t="hist";break;case x.PNUnsubscribeOperation:case x.PNWhereNowOperation:case x.PNHereNowOperation:case x.PNHeartbeatOperation:case x.PNSetStateOperation:case x.PNGetStateOperation:t="pres";break;case x.PNAddChannelsToGroupOperation:case x.PNRemoveChannelsFromGroupOperation:case x.PNChannelGroupsOperation:case x.PNRemoveGroupOperation:case x.PNChannelsForGroupOperation:t="cg";break;case x.PNPushNotificationEnabledChannelsOperation:case x.PNRemoveAllPushNotificationsOperation:t="push";break;case x.PNCreateUserOperation:case x.PNUpdateUserOperation:case x.PNDeleteUserOperation:case x.PNGetUserOperation:case x.PNGetUsersOperation:case x.PNCreateSpaceOperation:case x.PNUpdateSpaceOperation:case x.PNDeleteSpaceOperation:case x.PNGetSpaceOperation:case x.PNGetSpacesOperation:case x.PNGetMembersOperation:case x.PNUpdateMembersOperation:case x.PNGetMembershipsOperation:case x.PNUpdateMembershipsOperation:t="obj";break;case x.PNAddMessageActionOperation:case x.PNRemoveMessageActionOperation:case x.PNGetMessageActionsOperation:t="msga";break;case x.PNAccessManagerGrant:case x.PNAccessManagerAudit:t="pam";break;case x.PNAccessManagerGrantToken:case x.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,f=i.length>0;(l||p||f)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),f&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var h=a.length>0,d=s.length>0,y=u.length>0;return(h||d||y)&&(c.patterns={},h&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return x.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return x.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return x.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return x.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return x.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var fe=Object.freeze({__proto__:null,getOperation:function(){return x.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return x.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return x.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return x.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return x.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return x.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:b(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},be=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,f=e.file,h=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,b,v,_,S,w,O,P,E,T,A,C,k,N,M,j,R,U,x,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!f)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(f),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,b=o.url,v=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=v,e.mimeType&&(P=v.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&f.uri?(A=(T=p).POSTFILE,C=[b,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[b,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,U=[b,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,U.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(x=p).POSTFILE,D=[b,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(x,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:h,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},ve=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return x.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return x.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return x.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return x.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return x.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return x.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return x.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return x.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return x.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return x.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return x.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return x.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&f.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&f.include.push("uuid")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return x.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return x.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&f.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&f.include.push("channel")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var Ue=Object.freeze({__proto__:null,getOperation:function(){return x.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var xe=Object.freeze({__proto__:null,getOperation:function(){return x.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,f=void 0!==p&&p,h=t.manage,d=void 0!==h&&h,y=t.get,g=void 0!==y&&y,m=t.join,b=void 0!==m&&m,v=t.update,_=void 0!==v&&v,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=f?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=b?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,f=o.spaces,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,f=o.channels,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return x.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),f=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),h=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||h||p||d||f||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return x.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:b(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return x.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return x.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return x.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return x.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return x.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return x.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,f=t.includeUUID,h=void 0===f||f,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),h&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return x.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return x.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return x.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return x.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],f=l[1],h=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var b=this.currentContext;this.currentContext=f,this.notify({type:"transitionDone",fromState:m,fromContext:b,toState:p,toContext:f,event:e});try{for(var v=a(h),_=v.next();!_.done;_=v.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=v.return)&&o.call(v)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&a(e),[2]}))}))}))),r.on(ft.type,ut((function(e,t,n){var a=n.emitStatus;return o(r,void 0,void 0,(function(){return i(this,(function(t){return a(e),[2]}))}))}))),r.on(ht.type,ut((function(e,n,a){var s=a.receiveEvents,u=a.delay,c=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Tt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(At(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Ct())];case 7:return[2]}}))}))}))),r.on(dt.type,ut((function(e,n,a){var s=a.handshake,u=a.delay,c=a.presenceState,l=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,filterExpression:l.filterExpression,state:c})];case 3:return r=i.sent(),[2,t.transition(St(r))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Ot())];case 7:return[2]}}))}))}))),r}return t(n,e),n}(tt),jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),jt.on(mt.type,(function(e){return Gt.with(n({},e))}));var Rt=new Ze("HANDSHAKE_FAILURE");Rt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Rt.on(mt.type,(function(e){return Gt.with(n({},e))}));var Ut=new Ze("STOPPED");Ut.on(yt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(bt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(mt.type,(function(e){return Gt.with({channels:e.channels,groups:e.groups})})),Ut.on(Nt.type,(function(){return Lt.with(void 0)}));var xt=new Ze("RECEIVE_FAILED");xt.on(kt.type,(function(e){return Gt.with({channels:e.channels,groups:e.groups,timetoken:e.cursor.timetoken})})),xt.on(gt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),xt.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),xt.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),xt.on(Nt.type,(function(e){return Lt.with(void 0)}));var It=new Ze("RECEIVE_RECONNECTING");It.onEnter((function(e){return ht(e)})),It.onExit((function(){return ht.cancel})),It.on(Tt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(At.type,(function(e,t){return It.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),It.on(Ct.type,(function(e){return xt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:e.reason},[ft({category:R.PNDisconnectedUnexpectedlyCategory})])})),It.on(gt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),It.on(bt.type,(function(e,t){var n,r;return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:null!==(n=t.payload.timetoken)&&void 0!==n?n:e.cursor.timetoken,region:null!==(r=t.payload.region)&&void 0!==r?r:e.cursor.region}})})),It.on(yt.type,(function(e,t){return Dt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),It.on(Nt.type,(function(e){return Lt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("RECEIVING");Dt.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),Dt.onExit((function(){return lt.cancel})),Dt.on(Pt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Dt.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Lt.with(void 0):Dt.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(Et.type,(function(e,t){return It.with(n(n({},e),{attempts:0,reason:t.payload}))})),Dt.on(gt.type,(function(e){return Ut.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),Dt.on(Nt.type,(function(e){return Lt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Ft=new Ze("HANDSHAKE_RECONNECTING");Ft.onEnter((function(e){return dt(e)})),Ft.onExit((function(){return dt.cancel})),Ft.on(St.type,(function(e,t){var n=e.timetoken?{timetoken:e.timetoken,region:1}:t.payload.cursor;return Dt.with({channels:e.channels,groups:e.groups,cursor:n},[ft({category:R.PNConnectedCategory})])})),Ft.on(wt.type,(function(e,t){return Ft.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ft.on(Ot.type,(function(e){return Rt.with({groups:e.groups,channels:e.channels,reason:e.reason},[ft({category:R.PNConnectionErrorCategory})])})),Ft.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups},[ft({category:R.PNDisconnectedCategory})])})),Ft.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(Nt.type,(function(e){return Lt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Gt=new Ze("HANDSHAKING");Gt.onEnter((function(e){return ct(e.channels,e.groups)})),Gt.onExit((function(){return ct.cancel})),Gt.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Lt.with(void 0):Gt.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:{timetoken:e.timetoken&&"0"!==e.timetoken?e.timetoken:t.payload.timetoken,region:t.payload.region}},[ft({category:R.PNConnectedCategory})])})),Gt.on(_t.type,(function(e,t){return Ft.with(n(n({},e),{attempts:0,reason:t.payload}))})),Gt.on(gt.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Gt.on(Nt.type,(function(e){return Lt.with()})),Gt.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Lt=new Ze("UNSUBSCRIBED");Lt.on(yt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})})),Lt.on(bt.type,(function(e,t){return Gt.with({channels:t.payload.channels,groups:t.payload.groups,timetoken:t.payload.timetoken})}));var Kt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Mt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Lt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(bt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(){this.engine.transition(mt())},e.prototype.disconnect=function(){this.engine.transition(gt()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Bt=nt("RECONNECT",(function(){return{}})),Ht=nt("DISCONNECT",(function(){return{}})),qt=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),Vt=nt("LEFT_ALL",(function(){return{}})),Wt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Jt=nt("HEARTBEAT_FAILURE",(function(e){return e})),$t=nt("HEARTBEAT_GIVEUP",(function(){return{}})),Qt=nt("TIMES_UP",(function(){return{}})),Xt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Yt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Zt=rt("EMIT_STATUS",(function(e){return e})),en=ot("WAIT",(function(){return{}})),tn=ot("DELAYED_HEARTBEAT",(function(e){return e})),nn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Xt.type,ut((function(e,n,r){var s=r.heartbeat,u=r.presenceState;return o(a,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,s({channels:e.channels,channelGroups:e.groups,state:u})];case 1:return n=o.sent(),console.log("heartbeat Success: result = ",n,"\n\n",JSON.stringify(n)),t.transition(Wt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Jt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(en.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition(Qt())]}}))}))}))),a.on(tn.type,ut((function(e,n,r){var s=r.heartbeat,u=r.retryDelay,c=r.presenceState,l=r.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:o.sent(),n.throwIfAborted(),o.label=2;case 2:return o.trys.push([2,4,,5]),[4,s({channels:e.channels,channelGroups:e.groups,state:c})];case 3:return o.sent(),[2,t.transition(Wt(200))];case 4:return(r=o.sent())instanceof Error&&"Aborted"===r.message?[2]:r instanceof q?[2,t.transition(Jt(r))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition($t())];case 7:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?(console.log("failed => payload.status :",e.status),s(e.status)):u.announceSuccessfulHeartbeats&&200===e.statusCode&&(console.log("need to announce... received event.payload = ",e),s(n(n({},e),{operation:x.PNHeartbeatOperation,error:!1}))),[2]}))}))}))),a}return t(r,e),r}(tt),rn=new Ze("HEARTBEAT_STOPPED");rn.on(qt.type,(function(e,t){return rn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(zt.type,(function(e,t){return rn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e,t){return un.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),rn.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var on=new Ze("HEARTBEATCOOLDOWN");on.onEnter((function(){return en()})),on.onExit((function(){return en.cancel})),on.on(Qt.type,(function(e,t){return un.with({channels:e.channels,groups:e.groups})})),on.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),on.on(Ht.type,(function(e){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),on.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var an=new Ze("HEARTBEAT_FAILED");an.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){return un.with({channels:e.channels,groups:e.groups})})),an.on(Ht.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var sn=new Ze("HEARBEAT_RECONNECTING");sn.onEnter((function(e){return tn(e)})),sn.onExit((function(){return tn.cancel})),sn.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),sn.on(Ht.type,(function(e,t){rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),sn.on(Wt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),sn.on(Jt.type,(function(e,t){return sn.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),sn.on($t.type,(function(e,t){return an.with({channels:e.channels,groups:e.groups})})),sn.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var un=new Ze("HEARTBEATING");un.onEnter((function(e){return Xt(e.channels,e.groups)})),un.on(Wt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups},[Zt(t.payload)])})),un.on(qt.type,(function(e,t){return un.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),un.on(zt.type,(function(e,t){return un.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Yt(t.payload.channels,t.payload.groups)])})),un.on(Jt.type,(function(e,t){return sn.with(n(n({},e),{attempts:0,reason:t.payload}),[Zt(t.payload)])})),un.on(Ht.type,(function(e){return rn.with({channels:e.channels,groups:e.groups},[Yt(e.channels,e.groups)])})),un.on(Vt.type,(function(e,t){return cn.with(void 0,[Yt(e.channels,e.groups)])}));var cn=new Ze("HEARTBEAT_INACTIVE");cn.on(qt.type,(function(e,t){return un.with({channels:t.payload.channels,groups:t.payload.groups})})),cn.on(zt.type,(function(e,t){return cn.with()}));var ln=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new nn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(cn,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(qt(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(zt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(Vt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),pn=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){return 1e3*this.delay}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){var t=1e3*Math.trunc(Math.pow(2,e))+1e3*Math.random();return t>15e4?15e4:t}}},e}(),fn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var f=e.payload;if(this.modules.cryptoModule){var h=void 0;try{h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=f.message,a.file={id:f.file.id,name:f.file.name,url:this.getFileUrl({id:f.file.id,name:f.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){h=void 0;try{var d;h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=h?h:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype.emitStatus=function(e){},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var f=new I({maximumSamplesCount:6e4});this._telemetryManager=f;var h=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:f,PubNubFile:e.PubNubFile,cryptoModule:h};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),v=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new fn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return ve(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new ln({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Kt({handshake:this.handshake,receiveEvents:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitEvents:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.eventEngine=P}else{var E=new U({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:v,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return ve(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,xe),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,Ue),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,fe),this.removeMessageAction=Q.bind(this,d,he),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=be({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return ve(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function yn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?yn(a):a})),n}var gn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),mn={exports:{}},bn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void Tn(_n,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void Tn(_n,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=Pn());var o,i=Nn(e,"",0,[],void 0,0,r)||e;try{o=0===On.length?JSON.stringify(i,t,n):JSON.stringify(i,Mn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wn.length;){var a=wn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Nn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void Tn(_n,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void Tn(_n,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new qn('"allowMissing" argument must be a boolean');var n=lr(e),r=n.length>0?n[0]:"",o=pr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],ir(n,or([0,1],u)));for(var c=1,l=!0;c=n.length){var d=Vn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=rr(a,p),a=a[p];l&&!s&&(Zn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Ln,n=fr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var dr=fr,yr=hr.exports,gr=yr(dr("String.prototype.indexOf")),mr=l(Object.freeze({__proto__:null,default:{}})),br="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&br?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,_r=br&&vr&&"function"==typeof vr.get?vr.get:null,Sr=br&&Map.prototype.forEach,wr="function"==typeof Set&&Set.prototype,Or=Object.getOwnPropertyDescriptor&&wr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Pr=wr&&Or&&"function"==typeof Or.get?Or.get:null,Er=wr&&Set.prototype.forEach,Tr="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Ar="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Cr="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Nr=Object.prototype.toString,Mr=Function.prototype.toString,jr=String.prototype.match,Rr=String.prototype.slice,Ur=String.prototype.replace,xr=String.prototype.toUpperCase,Ir=String.prototype.toLowerCase,Dr=RegExp.prototype.test,Fr=Array.prototype.concat,Gr=Array.prototype.join,Lr=Array.prototype.slice,Kr=Math.floor,Br="function"==typeof BigInt?BigInt.prototype.valueOf:null,Hr=Object.getOwnPropertySymbols,qr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,zr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Vr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===zr||"symbol")?Symbol.toStringTag:null,Wr=Object.prototype.propertyIsEnumerable,Jr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function $r(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Dr.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Kr(-e):Kr(e);if(r!==e){var o=String(r),i=Rr.call(t,o.length+1);return Ur.call(o,n,"$&_")+"."+Ur.call(Ur.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Ur.call(t,n,"$&_")}var Qr=mr,Xr=Qr.custom,Yr=ro(Xr)?Xr:null;function Zr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function eo(e){return Ur.call(String(e),/"/g,""")}function to(e){return!("[object Array]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}function no(e){return!("[object RegExp]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}function ro(e){if(zr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!qr)return!1;try{return qr.call(e),!0}catch(e){}return!1}var oo=Object.prototype.hasOwnProperty||function(e){return e in this};function io(e,t){return oo.call(e,t)}function ao(e){return Nr.call(e)}function so(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return uo(Rr.call(e,0,t.maxStringLength),t)+r}return Zr(Ur.call(Ur.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,co),"single",t)}function co(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function lo(e){return"Object("+e+")"}function po(e){return e+" { ? }"}function fo(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Gr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Gr.call(e,","+n)+"\n"+t.prev}function yo(e,t){var n=to(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?yr(n):n},bo=function e(t,n,r,o){var i=n||{};if(io(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(io(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!io(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(io(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(io(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return uo(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?$r(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?$r(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return to(t)?"[Array]":"[Object]";var f=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Gr.call(Array(e.indent+1)," ")}return{base:n,prev:Gr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(so(o,t)>=0)return"[Circular]";function h(t,n,a){if(n&&(o=Lr.call(o)).push(n),a){var s={depth:i.depth};return io(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!no(t)){var d=function(e){if(e.name)return e.name;var t=jr.call(Mr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=yo(t,h);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Gr.call(y,", ")+" }":"")}if(ro(t)){var g=zr?Ur.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):qr.call(t);return"object"!=typeof t||zr?g:lo(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ir.call(String(t.nodeName)),b=t.attributes||[],v=0;v"}if(to(t)){if(0===t.length)return"[]";var _=yo(t,h);return f&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,f)+"]":"[ "+Gr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t)){var S=yo(t,h);return"cause"in Error.prototype||!("cause"in t)||Wr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Gr.call(S,", ")+" }":"{ ["+String(t)+"] "+Gr.call(Fr.call("[cause]: "+h(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Yr&&"function"==typeof t[Yr]&&Qr)return Qr(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!_r||!e||"object"!=typeof e)return!1;try{_r.call(e);try{Pr.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return Sr&&Sr.call(t,(function(e,n){w.push(h(n,t,!0)+" => "+h(e,t))})),fo("Map",_r.call(t),w,f)}if(function(e){if(!Pr||!e||"object"!=typeof e)return!1;try{Pr.call(e);try{_r.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Er&&Er.call(t,(function(e){O.push(h(e,t))})),fo("Set",Pr.call(t),O,f)}if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Ar.call(e,Ar)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return po("WeakMap");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{Ar.call(e,Ar);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return po("WeakSet");if(function(e){if(!Cr||!e||"object"!=typeof e)return!1;try{return Cr.call(e),!0}catch(e){}return!1}(t))return po("WeakRef");if(function(e){return!("[object Number]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t))return lo(h(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Br)return!1;try{return Br.call(e),!0}catch(e){}return!1}(t))return lo(h(Br.call(t)));if(function(e){return!("[object Boolean]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t))return lo(kr.call(t));if(function(e){return!("[object String]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t))return lo(h(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==ao(e)||Vr&&"object"==typeof e&&Vr in e)}(t)&&!no(t)){var P=yo(t,h),E=Jr?Jr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&Vr&&Object(t)===t&&Vr in t?Rr.call(ao(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Gr.call(Fr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":f?C+"{"+ho(P,f)+"}":C+"{ "+Gr.call(P,", ")+" }"}return String(t)},vo=go("%TypeError%"),_o=go("%WeakMap%",!0),So=go("%Map%",!0),wo=mo("WeakMap.prototype.get",!0),Oo=mo("WeakMap.prototype.set",!0),Po=mo("WeakMap.prototype.has",!0),Eo=mo("Map.prototype.get",!0),To=mo("Map.prototype.set",!0),Ao=mo("Map.prototype.has",!0),Co=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,No=/%20/g,Mo="RFC3986",jo={default:Mo,formatters:{RFC1738:function(e){return ko.call(e,No,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:Mo},Ro=jo,Uo=Object.prototype.hasOwnProperty,xo=Array.isArray,Io=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Do=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===Ro.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Io[u]:u<2048?a+=Io[192|u>>6]+Io[128|63&u]:u<55296||u>=57344?a+=Io[224|u>>12]+Io[128|u>>6&63]+Io[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Io[240|u>>18]+Io[128|u>>12&63]+Io[128|u>>6&63]+Io[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?b.join(",")||null:void 0}];else if(qo(u))O=u;else{var E=Object.keys(b);O=c?E.sort(c):E}for(var T=o&&qo(b)&&1===b.length?n+"[]":n,A=0;A-1?e.split(","):e},oi=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Zo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},ii=function(e,t){var n,r=e,o=function(e){if(!e)return $o;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||$o.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Ko.default;if(void 0!==e.format){if(!Bo.call(Ko.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Ko.formatters[n],o=$o.filter;return("function"==typeof e.filter||qo(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:$o.addQueryPrefix,allowDots:void 0===e.allowDots?$o.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:$o.charsetSentinel,delimiter:void 0===e.delimiter?$o.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:$o.encode,encoder:"function"==typeof e.encoder?e.encoder:$o.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:$o.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:$o.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:$o.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:$o.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):qo(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Ho?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Ho[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Go(),l=0;l0?h+f:""},ai={formats:jo,parse:function(e,t){var n=function(e){if(!e)return ti;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ti.charset:e.charset;return{allowDots:void 0===e.allowDots?ti.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ti.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ti.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ti.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ti.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ti.comma,decoder:"function"==typeof e.decoder?e.decoder:ti.decoder,delimiter:"string"==typeof e.delimiter||Yo.isRegExp(e.delimiter)?e.delimiter:ti.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ti.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ti.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ti.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ti.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ti.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=ei(l)?[l]:l),Zo.call(r,c)?r[c]=Yo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(si);const ui=mr,ci=si.isObject,li=si.hasOwn;var pi=fi;function fi(){}fi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},fi.prototype.parse=function(e){return this._parser=e,this},fi.prototype.responseType=function(e){return this._responseType=e,this},fi.prototype.serialize=function(e){return this._serializer=e,this},fi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(li(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},fi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),di=new Set([408,413,429,500,502,503,504,521,522,524]);fi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&di.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},fi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},fi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},fi.prototype.catch=function(e){return this.then(void 0,e)},fi.prototype.use=function(e){return e(this),this},fi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},fi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},fi.prototype.get=function(e){return this._header[e.toLowerCase()]},fi.prototype.getHeader=fi.prototype.get,fi.prototype.set=function(e,t){if(ci(e)){for(const t in e)li(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},fi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},fi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ci(e)){for(const t in e)li(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)li(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},fi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(ui.gte(process.version,"v13.0.0")&&ui.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},fi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},fi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},fi.prototype.redirects=function(e){return this._maxRedirects=e,this},fi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},fi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},fi.prototype.send=function(e){const t=ci(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ci(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");li(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},fi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},fi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},fi.prototype._appendQueryString=()=>{console.warn("Unsupported")},fi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},fi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const yi=si;var gi=mi;function mi(){}function bi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&b(t,n,e[n]);return t.join("&")}function b(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){b(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&b(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function v(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=v,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":v,"application/json":JSON.parse},l(S.prototype,f.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new h;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(mn,mn.exports);var Pi=mn.exports;function Ei(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ti(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Ei)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ai(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Pi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ci(e,t,n){var r=Pi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ti.call(this,r,t,n)}function ki(e,t,n){var r=Pi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ti.call(this,r,t,n)}function Ni(e,t,n,r){var o=Pi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ti.call(this,o,n,r)}function Mi(e,t,n,r){var o=Pi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ti.call(this,o,n,r)}function ji(e,t,n){var r=Pi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ti.call(this,r,t,n)}function Ri(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ui,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=Ri,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=Ri(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ii=(Ui=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ui.supportsFile="undefined"!=typeof File,Ui.supportsBlob="undefined"!=typeof Blob,Ui.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ui.supportsBuffer=!1,Ui.supportsStream=!1,Ui.supportsString=!0,Ui.supportsEncryptFile=!0,Ui.supportsFileUri=!1,Ui),Di=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:b(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Fi=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Li.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Li.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Ki)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Li.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Li=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Ki(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Ki(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Ki=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Li.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Li.SENTINEL.length+1+Li.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Li.SENTINEL)),t[e+=Li.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Li.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Bi(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Hi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new dn({del:ji,get:ki,post:Ni,patch:Mi,sendBeacon:Bi,getfile:Ci,postfile:Ai}),t.cbor=new gn((function(e){return yn(f.decode(e))}),m),t.PubNubFile=Ii,t.cryptography=new xi,t.initCryptoModule=function(e){return new Gi({default:new Di({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Fi({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Gi,n}(hn);return Hi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(f,f.exports);var h=f.exports,y=function(){return h.uuid?h.uuid():h()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function v(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,h=(3&l)<<6|p>>0;o[s]=d,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=h)}return r}function m(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),d=2;d<=p;d++)if(!(l%d)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],d=0;64>d;d++){if(16>d)f[d]=0|e[t+d];else{var h=f[d-15],y=f[d-2];f[d]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+f[d-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[d-16]}h=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[d]+f[d],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+h|0,s=i,i=o,o=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],d=e[i+4],f=e[i+5],h=e[i+6],y=e[i+7],g=e[i+8],v=e[i+9],m=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,d,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,h,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,v,12,c[9]),T=t(T,E,P,A,m,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,h,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,m,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,d,20,c[23]),P=n(P,A,T,E,v,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,d,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,m,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,h,23,c[43]),P=r(P,A,T,E,v,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,m,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,h,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,d,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,v,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),d=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},h=t.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=d.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],d=[],f=[],h=0;256>h;h++)f[h]=128>h?h<<1:h<<1^283;var y=0,g=0;for(h=0;256>h;h++){var v=(v=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&v^99;r[y]=v,o[v]=y;var m=f[y],b=f[m],_=f[b],S=257*f[v]^16843008*v;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*m^16843008*y,c[v]=S<<24|S>>>8,l[v]=S<<16|S>>>16,p[v]=S<<8|S>>>24,d[v]=S,y?(y=m^f[f[f[_^m]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^d[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,d,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],d=e[t+3]^n[3],f=4,h=1;h>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&d]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[d>>>8&255]^a[255&c]^n[f++],v=r[p>>>24]^o[d>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];d=r[d>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=v}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&d])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[d>>>8&255]<<8|s[255&c])^n[f++],v=(s[p>>>24]<<24|s[d>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],d=(s[d>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=v,e[t+3]=d},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,d=r(u,["uuid","channel"]);d.user=l,d.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:d})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var h=void 0;try{h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){h=void 0;try{var g;h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=h?h:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,d=i.length>0;(l||p||d)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),d&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,h=s.length>0,y=u.length>0;return(f||h||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),h&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ve={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},me=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,d=e.file,f=e.message,h=e.cipherKey,y=e.meta,g=e.ttl,v=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,m,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!d)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(d),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,m=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(h||l)?null!=h?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(h,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&d.uri?(A=(T=p).POSTFILE,k=[m,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[m,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[m,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[m,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:v,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&v.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&v.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&v.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&v.include.push("uuid.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&d.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&d.include.push("uuid")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&v.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&v.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&v.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&v.include.push("channel.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,d=void 0!==p&&p,f=t.manage,h=void 0!==f&&f,y=t.get,g=void 0!==y&&y,v=t.join,m=void 0!==v&&v,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=d?"1":"0",P.m=h?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=m?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,d=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,d=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),d=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),h=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||h||d||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,d=t.includeUUID,f=void 0===d||d,h=t.includeMessageType,y=void 0===h||h,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],d=l[1],f=l[2];try{for(var h=a(this.currentState.exitEffects),y=h.next();!y.done;y=h.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var m=this.currentContext;this.currentContext=d,this.notify({type:"transitionDone",fromState:v,fromContext:m,toState:p,toContext:d,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&a(e),[2]}))}))}))),r.on(dt.type,ut((function(e,t,n){var a=n.emitStatus;return o(r,void 0,void 0,(function(){return i(this,(function(t){return a(e),[2]}))}))}))),r.on(ft.type,ut((function(e,n,a){var s=a.receiveMessages,u=a.delay,c=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r.on(ht.type,ut((function(e,n,a){var s=a.handshake,u=a.delay,c=a.presenceState,l=a.config;return o(r,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={abortSignal:n,channels:e.channels,channelGroups:e.groups,filterExpression:l.filterExpression},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(l.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r}return t(n,e),n}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){var n,r,o,i,a;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(o=null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.timetoken)&&void 0!==o?o:"0",region:null!==(a=null===(i=t.payload)||void 0===i?void 0:i.region)&&void 0!==a?a:0}})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){var r,o,i,a,s,u;return Ft.with(n(n({},e),{cursor:{timetoken:null!==(a=null!==(o=null===(r=t.payload)||void 0===r?void 0:r.timetoken)&&void 0!==o?o:null===(i=e.cursor)||void 0===i?void 0:i.timetoken)&&void 0!==a?a:"0",region:null!==(u=null===(s=t.payload)||void 0===s?void 0:s.region)&&void 0!==u?u:0}}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:"0",region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:0}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){var n,r;return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.cursor.timetoken,region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[dt({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){var n,r;return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){var n,r;return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ht(e)})),Dt.onExit((function(){return ht.cancel})),Dt.on(bt.type,(function(e,t){var n,r={timetoken:null!==(n=null==e?void 0:e.timetoken)&&void 0!==n?n:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:r},[dt({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,timetoken:e.timetoken,reason:t.payload},[dt({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){var t;return jt.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(t=e.timetoken)&&void 0!==t?t:"0",region:0}})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(vt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=e.cursor)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:t.payload.timetoken,region:t.payload.region}},[dt({category:R.PNConnectedCategory})])})),Ft.on(mt.type,(function(e,t){var n;return Dt.with({channels:e.channels,groups:e.groups,timetoken:null===(n=e.cursor)||void 0===n?void 0:n.timetoken,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,n,r){var s=r.heartbeat,u=r.presenceState,c=r.config;return o(a,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),n={channels:e.channels,channelGroups:e.groups},c.maintainPresenceState&&(n.state=u),[4,s(n)];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,n,r){var s=r.heartbeat,u=r.retryDelay,c=r.presenceState,l=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(t){return{delay:t.delay,maximumRetry:t.maximumRetry,shouldRetry:function(t,n){var r;return!e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)&&this.maximumRetry>n},getDelay:function(e){return 1e3*(this.delay+Math.random())},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.ExponentialRetryPolicy=function(t){return{minimumDelay:t.minimumDelay,maximumDelay:t.maximumDelay,maximumRetry:t.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){var t=1e3*(Math.pow(2,e)+Math.random());return t>this.maximumDelay?this.maximumDelay:t},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.excludedErrorCodes=[403,429],e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var d=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(d=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=d.message,a.file={id:d.file.id,name:d.file.name,url:this.getFileUrl({id:d.file.id,name:d.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var h;f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),dn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var d=new I({maximumSamplesCount:6e4});this._telemetryManager=d;var f=this._config.cryptoModule,h={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:d,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,h,Je),v=Q.bind(this,h,ae),b=Q.bind(this,h,ue),_=Q.bind(this,h,le),S=Q.bind(this,h,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,h,ue),this.iAmAway=Q.bind(this,h,ae),this.setPresenceState=Q.bind(this,h,le),this.handshake=Q.bind(this,h,Qe),this.receiveMessages=Q.bind(this,h,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:h,listenerManager:this._listenerManager,getFileUrl:function(e){return be(h,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*h.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:h.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:h.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:h.crypto,config:h.config,listenerManager:w,getFileUrl:function(e){return be(h,e)},cryptoModule:h.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,h,ee),listChannels:Q.bind(this,h,te),addChannels:Q.bind(this,h,X),removeChannels:Q.bind(this,h,Y),deleteGroup:Q.bind(this,h,Z)},this.push={addChannels:Q.bind(this,h,ne),removeChannels:Q.bind(this,h,re),deleteDevice:Q.bind(this,h,ie),listChannels:Q.bind(this,h,oe)},this.hereNow=Q.bind(this,h,pe),this.whereNow=Q.bind(this,h,se),this.getState=Q.bind(this,h,ce),this.grant=Q.bind(this,h,Ue),this.grantToken=Q.bind(this,h,Ge),this.audit=Q.bind(this,h,xe),this.revokeToken=Q.bind(this,h,Le),this.publish=Q.bind(this,h,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,h,He),this.history=Q.bind(this,h,qe),this.deleteMessages=Q.bind(this,h,ze),this.messageCounts=Q.bind(this,h,Ve),this.fetchMessages=Q.bind(this,h,We),this.addMessageAction=Q.bind(this,h,de),this.removeMessageAction=Q.bind(this,h,fe),this.getMessageActions=Q.bind(this,h,he),this.listFiles=Q.bind(this,h,ye);var T=Q.bind(this,h,ge);this.publishFile=Q.bind(this,h,ve),this.sendFile=me({generateUploadUrl:T,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return be(h,e)},this.downloadFile=Q.bind(this,h,_e),this.deleteFile=Q.bind(this,h,Se),this.objects={getAllUUIDMetadata:Q.bind(this,h,we),getUUIDMetadata:Q.bind(this,h,Oe),setUUIDMetadata:Q.bind(this,h,Pe),removeUUIDMetadata:Q.bind(this,h,Ee),getAllChannelMetadata:Q.bind(this,h,Te),getChannelMetadata:Q.bind(this,h,Ae),setChannelMetadata:Q.bind(this,h,ke),removeChannelMetadata:Q.bind(this,h,Ce),getChannelMembers:Q.bind(this,h,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function hn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?hn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},vn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var h=zn(a,p);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},dr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(dr);var fr=pr,hr=dr.exports,yr=hr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),vr="function"==typeof Map&&Map.prototype,mr=Object.getOwnPropertyDescriptor&&vr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=vr&&mr&&"function"==typeof mr.get?mr.get:null,_r=vr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?hr(n):n},vo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var d=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var h=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,f);return"[Function"+(h?": "+h:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var v="<"+Ur.call(String(t.nodeName)),m=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,f);return d&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,d)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,d)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,d)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":d?k+"{"+fo(P,d)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},mo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?m.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(m);O=c?E.sort(c):E}for(var T=o&&Ho(m)&&1===m.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+d:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const di=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&di.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const hi=ai;var yi=gi;function gi(){}function vi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function mi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function v(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&m(t,n,e[n]);return t.join("&")}function m(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){m(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&m(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=v,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,d.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=v(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||h,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:m(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:v(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return hn(d.decode(e))}),v),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(dn);return Bi})); diff --git a/lib/core/components/config.js b/lib/core/components/config.js index 599032bff..c155e65fe 100644 --- a/lib/core/components/config.js +++ b/lib/core/components/config.js @@ -54,7 +54,7 @@ var default_1 = /** @class */ (function () { this.useRequestId = setup.useRequestId || false; this.requestMessageCountThreshold = setup.requestMessageCountThreshold; if (setup.retryConfiguration) { - this.setRetryConfiguration(setup.retryConfiguration); + this._setRetryConfiguration(setup.retryConfiguration); } // set timeout to how long a transaction request will wait for the server (default 15 seconds) this.setTransactionTimeout(setup.transactionalRequestTimeout || 15 * 1000); @@ -182,7 +182,7 @@ var default_1 = /** @class */ (function () { default_1.prototype.getVersion = function () { return '7.4.5'; }; - default_1.prototype.setRetryConfiguration = function (configuration) { + default_1.prototype._setRetryConfiguration = function (configuration) { if (configuration.minimumdelay < 2) { throw new Error('Minimum delay can not be set less than 2 seconds for retry'); } diff --git a/lib/core/components/eventEmitter.js b/lib/core/components/eventEmitter.js index 898c0c7e6..d9f6def25 100644 --- a/lib/core/components/eventEmitter.js +++ b/lib/core/components/eventEmitter.js @@ -199,8 +199,6 @@ var EventEmitter = /** @class */ (function () { this.listenerManager.announceMessage(announce); } }; - EventEmitter.prototype.emitStatus = function (s) { - }; EventEmitter.prototype._renameEvent = function (e) { return e === 'set' ? 'updated' : 'removed'; }; diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index b87afee9e..b321cf59e 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -238,14 +238,14 @@ var default_1 = /** @class */ (function () { } var eventEngine = new event_engine_1.EventEngine({ handshake: this.handshake, - receiveEvents: this.receiveMessages, + receiveMessages: this.receiveMessages, delay: function (amount) { return new Promise(function (resolve) { return setTimeout(resolve, amount); }); }, join: this.join, leave: this.leave, leaveAll: this.leaveAll, presenceState: this.presenceState, config: modules.config, - emitEvents: function (events) { + emitMessages: function (events) { var e_1, _a; try { for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) { @@ -270,6 +270,7 @@ var default_1 = /** @class */ (function () { this.unsubscribeAll = eventEngine.unsubscribeAll.bind(eventEngine); this.reconnect = eventEngine.reconnect.bind(eventEngine); this.disconnect = eventEngine.disconnect.bind(eventEngine); + this.destroy = eventEngine.dispose.bind(eventEngine); this.eventEngine = eventEngine; } else { @@ -606,7 +607,6 @@ var default_1 = /** @class */ (function () { this.setUserId = modules.config.setUserId.bind(modules.config); this.getFilterExpression = modules.config.getFilterExpression.bind(modules.config); this.setFilterExpression = modules.config.setFilterExpression.bind(modules.config); - // this.setCipherKey = modules.config.setCipherKey.bind(modules.config); this.setCipherKey = function (key) { return modules.config.setCipherKey(key, setup, modules); }; this.setHeartbeatInterval = modules.config.setHeartbeatInterval.bind(modules.config); if (networking.hasModule('proxy')) { diff --git a/lib/event-engine/core/retryPolicy.js b/lib/event-engine/core/retryPolicy.js index fbce3277f..837bbb34d 100644 --- a/lib/event-engine/core/retryPolicy.js +++ b/lib/event-engine/core/retryPolicy.js @@ -10,13 +10,23 @@ var RetryPolicy = /** @class */ (function () { maximumRetry: configuration.maximumRetry, shouldRetry: function (error, attempt) { var _a; - if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { return false; } return this.maximumRetry > attempt; }, getDelay: function (_) { - return this.delay * 1000; + return (this.delay + Math.random()) * 1000; + }, + getGiveupReason: function (error, attempt) { + var _a; + if (this.maximumRetry <= attempt) { + return 'retry attempts exhaused.'; + } + if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { + return 'forbidden or too many requests.'; + } + return 'unknown error'; }, }; }; @@ -33,16 +43,27 @@ var RetryPolicy = /** @class */ (function () { return this.maximumRetry > attempt; }, getDelay: function (attempt) { - var calculatedDelay = Math.trunc(Math.pow(2, attempt)) * 1000 + Math.random() * 1000; - if (calculatedDelay > 150000) { - return 150000; + var calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; + if (calculatedDelay > this.maximumDelay) { + return this.maximumDelay; } else { return calculatedDelay; } }, + getGiveupReason: function (error, attempt) { + var _a; + if (this.maximumRetry <= attempt) { + return 'retry attempts exhaused.'; + } + if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { + return 'forbidden or too many requests.'; + } + return 'unknown error'; + }, }; }; + RetryPolicy.excludedErrorCodes = [403, 429]; return RetryPolicy; }()); exports.RetryPolicy = RetryPolicy; diff --git a/lib/event-engine/dispatcher.js b/lib/event-engine/dispatcher.js index 477d06484..a41912cdc 100644 --- a/lib/event-engine/dispatcher.js +++ b/lib/event-engine/dispatcher.js @@ -86,7 +86,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _this.on(effects.handshake.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { var handshake = _a.handshake, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var result, e_1; + var handshakeParams, result, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -94,25 +94,25 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); - return [4 /*yield*/, handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - state: presenceState, - })]; + handshakeParams = { + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + filterExpression: config.filterExpression, + }; + if (config.maintainPresenceState) + handshakeParams.state = presenceState; + return [4 /*yield*/, handshake(handshakeParams)]; case 2: result = _b.sent(); - console.log("handshake response = ".concat(JSON.stringify(result))); - return [2 /*return*/, engine.transition(events.handshakingSuccess(result))]; + return [2 /*return*/, engine.transition(events.handshakeSuccess(result))]; case 3: e_1 = _b.sent(); - console.log('at effect, received error = ', e_1, '\n', "".concat(e_1)); if (e_1 instanceof Error && e_1.message === 'Aborted') { return [2 /*return*/]; } if (e_1 instanceof endpoint_1.PubNubError) { - return [2 /*return*/, engine.transition(events.handshakingFailure(e_1))]; + return [2 /*return*/, engine.transition(events.handshakeFailure(e_1))]; } return [3 /*break*/, 4]; case 4: return [2 /*return*/]; @@ -120,8 +120,8 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); }); })); - _this.on(effects.receiveEvents.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents, config = _a.config; + _this.on(effects.receiveMessages.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { + var receiveMessages = _a.receiveMessages, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_1; return __generator(this, function (_b) { @@ -131,7 +131,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); - return [4 /*yield*/, receiveEvents({ + return [4 /*yield*/, receiveMessages({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, @@ -141,7 +141,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { })]; case 2: result = _b.sent(); - engine.transition(events.receivingSuccess(result.metadata, result.messages)); + engine.transition(events.receiveSuccess(result.metadata, result.messages)); return [3 /*break*/, 4]; case 3: error_1 = _b.sent(); @@ -149,7 +149,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { return [2 /*return*/]; } if (error_1 instanceof endpoint_1.PubNubError && !abortSignal.aborted) { - return [2 /*return*/, engine.transition(events.receivingFailure(error_1))]; + return [2 /*return*/, engine.transition(events.receiveFailure(error_1))]; } return [3 /*break*/, 4]; case 4: return [2 /*return*/]; @@ -157,12 +157,12 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); }); })); - _this.on(effects.emitEvents.type, (0, core_1.asyncHandler)(function (payload, _, _a) { - var emitEvents = _a.emitEvents; + _this.on(effects.emitMessages.type, (0, core_1.asyncHandler)(function (payload, _, _a) { + var emitMessages = _a.emitMessages; return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) { if (payload.length > 0) { - emitEvents(payload); + emitMessages(payload); } return [2 /*return*/]; }); @@ -177,8 +177,8 @@ var EventEngineDispatcher = /** @class */ (function (_super) { }); }); })); - _this.on(effects.reconnect.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { - var receiveEvents = _a.receiveEvents, delay = _a.delay, config = _a.config; + _this.on(effects.receiveReconnect.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { + var receiveMessages = _a.receiveMessages, delay = _a.delay, config = _a.config; return __awaiter(_this, void 0, void 0, function () { var result, error_2; return __generator(this, function (_b) { @@ -193,7 +193,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, receiveEvents({ + return [4 /*yield*/, receiveMessages({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, @@ -203,18 +203,18 @@ var EventEngineDispatcher = /** @class */ (function (_super) { })]; case 3: result = _b.sent(); - return [2 /*return*/, engine.transition(events.reconnectingSuccess(result.metadata, result.messages))]; + return [2 /*return*/, engine.transition(events.receiveReconnectSuccess(result.metadata, result.messages))]; case 4: error_2 = _b.sent(); if (error_2 instanceof Error && error_2.message === 'Aborted') { return [2 /*return*/]; } if (error_2 instanceof endpoint_1.PubNubError) { - return [2 /*return*/, engine.transition(events.reconnectingFailure(error_2))]; + return [2 /*return*/, engine.transition(events.receiveReconnectFailure(error_2))]; } return [3 /*break*/, 5]; case 5: return [3 /*break*/, 7]; - case 6: return [2 /*return*/, engine.transition(events.reconnectingGiveup())]; + case 6: return [2 /*return*/, engine.transition(events.receiveReconnectGiveup(new endpoint_1.PubNubError(config.retryConfiguration.getGiveupReason(payload.reason, payload.attempts))))]; case 7: return [2 /*return*/]; } }); @@ -223,7 +223,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _this.on(effects.handshakeReconnect.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { var handshake = _a.handshake, delay = _a.delay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var result, error_3; + var handshakeParams, result, error_3; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -236,27 +236,29 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, handshake({ - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - state: presenceState, - })]; + handshakeParams = { + abortSignal: abortSignal, + channels: payload.channels, + channelGroups: payload.groups, + filterExpression: config.filterExpression, + }; + if (config.maintainPresenceState) + handshakeParams.state = presenceState; + return [4 /*yield*/, handshake(handshakeParams)]; case 3: result = _b.sent(); - return [2 /*return*/, engine.transition(events.handshakingReconnectingSuccess(result))]; + return [2 /*return*/, engine.transition(events.handshakeReconnectSuccess(result))]; case 4: error_3 = _b.sent(); if (error_3 instanceof Error && error_3.message === 'Aborted') { return [2 /*return*/]; } if (error_3 instanceof endpoint_1.PubNubError) { - return [2 /*return*/, engine.transition(events.handshakingReconnectingFailure(error_3))]; + return [2 /*return*/, engine.transition(events.handshakeReconnectFailure(error_3))]; } return [3 /*break*/, 5]; case 5: return [3 /*break*/, 7]; - case 6: return [2 /*return*/, engine.transition(events.handshakingReconnectingGiveup())]; + case 6: return [2 /*return*/, engine.transition(events.handshakeReconnectGiveup(new endpoint_1.PubNubError(config.retryConfiguration.getGiveupReason(payload.reason, payload.attempts))))]; case 7: return [2 /*return*/]; } }); diff --git a/lib/event-engine/effects.js b/lib/event-engine/effects.js index b9d1ea250..2b5ead623 100644 --- a/lib/event-engine/effects.js +++ b/lib/event-engine/effects.js @@ -1,13 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.handshakeReconnect = exports.reconnect = exports.emitStatus = exports.emitEvents = exports.receiveEvents = exports.handshake = void 0; +exports.handshakeReconnect = exports.receiveReconnect = exports.emitStatus = exports.emitMessages = exports.receiveMessages = exports.handshake = void 0; var core_1 = require("./core"); exports.handshake = (0, core_1.createManagedEffect)('HANDSHAKE', function (channels, groups) { return ({ channels: channels, groups: groups, }); }); -exports.receiveEvents = (0, core_1.createManagedEffect)('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); -exports.emitEvents = (0, core_1.createEffect)('EMIT_MESSAGES', function (events) { return events; }); +exports.receiveMessages = (0, core_1.createManagedEffect)('RECEIVE_MESSAGES', function (channels, groups, cursor) { return ({ channels: channels, groups: groups, cursor: cursor }); }); +exports.emitMessages = (0, core_1.createEffect)('EMIT_MESSAGES', function (events) { return events; }); exports.emitStatus = (0, core_1.createEffect)('EMIT_STATUS', function (status) { return status; }); -exports.reconnect = (0, core_1.createManagedEffect)('RECEIVE_RECONNECT', function (context) { return context; }); +exports.receiveReconnect = (0, core_1.createManagedEffect)('RECEIVE_RECONNECT', function (context) { return context; }); exports.handshakeReconnect = (0, core_1.createManagedEffect)('HANDSHAKE_RECONNECT', function (context) { return context; }); diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index 1e8688ebe..d33d16ab1 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -1,37 +1,38 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.unsubscribeAll = exports.reconnectingRetry = exports.reconnectingGiveup = exports.reconnectingFailure = exports.reconnectingSuccess = exports.receivingFailure = exports.receivingSuccess = exports.handshakingReconnectingGiveup = exports.handshakingReconnectingFailure = exports.handshakingReconnectingSuccess = exports.handshakingFailure = exports.handshakingSuccess = exports.restore = exports.reconnect = exports.disconnect = exports.subscriptionChange = void 0; +exports.unsubscribeAll = exports.reconnect = exports.disconnect = exports.receiveReconnectGiveup = exports.receiveReconnectFailure = exports.receiveReconnectSuccess = exports.receiveFailure = exports.receiveSuccess = exports.handshakeReconnectGiveup = exports.handshakeReconnectFailure = exports.handshakeReconnectSuccess = exports.handshakeFailure = exports.handshakeSuccess = exports.restore = exports.subscriptionChange = void 0; var core_1 = require("./core"); -exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', function (channels, groups, timetoken) { return ({ +exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', function (channels, groups) { return ({ channels: channels, groups: groups, - timetoken: timetoken, }); }); -exports.disconnect = (0, core_1.createEvent)('DISCONNECT', function () { return ({}); }); -exports.reconnect = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); exports.restore = (0, core_1.createEvent)('SUBSCRIPTION_RESTORED', function (channels, groups, timetoken, region) { return ({ channels: channels, groups: groups, timetoken: timetoken, region: region, }); }); -exports.handshakingSuccess = (0, core_1.createEvent)('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); -exports.handshakingFailure = (0, core_1.createEvent)('HANDSHAKE_FAILURE', function (error) { return error; }); -exports.handshakingReconnectingSuccess = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_SUCCESS', function (cursor) { return ({ +exports.handshakeSuccess = (0, core_1.createEvent)('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); +exports.handshakeFailure = (0, core_1.createEvent)('HANDSHAKE_FAILURE', function (error) { return error; }); +exports.handshakeReconnectSuccess = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_SUCCESS', function (cursor) { return ({ cursor: cursor, }); }); -exports.handshakingReconnectingFailure = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); -exports.handshakingReconnectingGiveup = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_GIVEUP', function () { return ({}); }); -exports.receivingSuccess = (0, core_1.createEvent)('RECEIVE_SUCCESS', function (cursor, events) { return ({ +exports.handshakeReconnectFailure = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_FAILURE', function (error) { return error; }); +exports.handshakeReconnectGiveup = (0, core_1.createEvent)('HANDSHAKE_RECONNECT_GIVEUP', function (error) { return error; }); +exports.receiveSuccess = (0, core_1.createEvent)('RECEIVE_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); -exports.receivingFailure = (0, core_1.createEvent)('RECEIVE_FAILURE', function (error) { return error; }); -exports.reconnectingSuccess = (0, core_1.createEvent)('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ +exports.receiveFailure = (0, core_1.createEvent)('RECEIVE_FAILURE', function (error) { return error; }); +exports.receiveReconnectSuccess = (0, core_1.createEvent)('RECEIVE_RECONNECT_SUCCESS', function (cursor, events) { return ({ cursor: cursor, events: events, }); }); -exports.reconnectingFailure = (0, core_1.createEvent)('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); -exports.reconnectingGiveup = (0, core_1.createEvent)('RECEIVING_RECONNECTING_GIVEUP', function () { return ({}); }); -exports.reconnectingRetry = (0, core_1.createEvent)('RECONNECT', function () { return ({}); }); +exports.receiveReconnectFailure = (0, core_1.createEvent)('RECEIVE_RECONNECT_FAILURE', function (error) { return error; }); +exports.receiveReconnectGiveup = (0, core_1.createEvent)('RECEIVING_RECONNECT_GIVEUP', function (error) { return error; }); +exports.disconnect = (0, core_1.createEvent)('DISCONNECT', function () { return ({}); }); +exports.reconnect = (0, core_1.createEvent)('RECONNECT', function (timetoken, region) { return ({ + timetoken: timetoken, + region: region, +}); }); exports.unsubscribeAll = (0, core_1.createEvent)('UNSUBSCRIBE_ALL', function () { return ({}); }); diff --git a/lib/event-engine/index.js b/lib/event-engine/index.js index 453f1092e..3f563237b 100644 --- a/lib/event-engine/index.js +++ b/lib/event-engine/index.js @@ -129,8 +129,9 @@ var EventEngine = /** @class */ (function () { this.dependencies.leaveAll(); } }; - EventEngine.prototype.reconnect = function () { - this.engine.transition(events.reconnect()); + EventEngine.prototype.reconnect = function (_a) { + var timetoken = _a.timetoken, region = _a.region; + this.engine.transition(events.reconnect(timetoken, region)); }; EventEngine.prototype.disconnect = function () { this.engine.transition(events.disconnect()); diff --git a/lib/event-engine/presence/dispatcher.js b/lib/event-engine/presence/dispatcher.js index 49704b161..8ac69096f 100644 --- a/lib/event-engine/presence/dispatcher.js +++ b/lib/event-engine/presence/dispatcher.js @@ -99,21 +99,22 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { function PresenceEventEngineDispatcher(engine, dependencies) { var _this = _super.call(this, dependencies) || this; _this.on(effects.heartbeat.type, (0, core_1.asyncHandler)(function (payload, _, _a) { - var heartbeat = _a.heartbeat, presenceState = _a.presenceState; + var heartbeat = _a.heartbeat, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var result, e_1; + var heartbeatParams, result, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); - return [4 /*yield*/, heartbeat({ - channels: payload.channels, - channelGroups: payload.groups, - state: presenceState, - })]; + heartbeatParams = { + channels: payload.channels, + channelGroups: payload.groups, + }; + if (config.maintainPresenceState) + heartbeatParams.state = presenceState; + return [4 /*yield*/, heartbeat(heartbeatParams)]; case 1: result = _b.sent(); - console.log('heartbeat Success: result = ', result, '\n\n', JSON.stringify(result)); engine.transition(events.heartbeatSuccess(200)); return [3 /*break*/, 3]; case 2: @@ -172,7 +173,7 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { _this.on(effects.delayedHeartbeat.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { var heartbeat = _a.heartbeat, retryDelay = _a.retryDelay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var result, e_3; + var heartbeatParams, result, e_3; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -185,11 +186,13 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - return [4 /*yield*/, heartbeat({ - channels: payload.channels, - channelGroups: payload.groups, - state: presenceState, - })]; + heartbeatParams = { + channels: payload.channels, + channelGroups: payload.groups, + }; + if (config.maintainPresenceState) + heartbeatParams.state = presenceState; + return [4 /*yield*/, heartbeat(heartbeatParams)]; case 3: result = _b.sent(); return [2 /*return*/, engine.transition(events.heartbeatSuccess(200))]; @@ -215,11 +218,9 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { var _b; return __generator(this, function (_c) { if (config.announceFailedHeartbeats && ((_b = payload === null || payload === void 0 ? void 0 : payload.status) === null || _b === void 0 ? void 0 : _b.error) === true) { - console.log('failed => payload.status :', payload.status); emitStatus(payload.status); } else if (config.announceSuccessfulHeartbeats && payload.statusCode === 200) { - console.log('need to announce... received event.payload = ', payload); emitStatus(__assign(__assign({}, payload), { operation: operations_1.default.PNHeartbeatOperation, error: false })); } return [2 /*return*/]; diff --git a/lib/event-engine/presence/states/heartbeat_cooldown.js b/lib/event-engine/presence/states/heartbeat_cooldown.js index 6a490375b..0ee9ba6ef 100644 --- a/lib/event-engine/presence/states/heartbeat_cooldown.js +++ b/lib/event-engine/presence/states/heartbeat_cooldown.js @@ -32,7 +32,7 @@ var effects_1 = require("../effects"); var heartbeating_1 = require("./heartbeating"); var heartbeat_stopped_1 = require("./heartbeat_stopped"); var heartbeat_inactive_1 = require("./heartbeat_inactive"); -exports.HeartbeatCooldownState = new state_1.State('HEARTBEATCOOLDOWN'); +exports.HeartbeatCooldownState = new state_1.State('HEARTBEAT_COOLDOWN'); exports.HeartbeatCooldownState.onEnter(function () { return (0, effects_1.wait)(); }); exports.HeartbeatCooldownState.onExit(function () { return effects_1.wait.cancel; }); exports.HeartbeatCooldownState.on(events_1.timesUp.type, function (context, _) { diff --git a/lib/event-engine/presence/states/heartbeat_inactive.js b/lib/event-engine/presence/states/heartbeat_inactive.js index 63c3de175..ec795611e 100644 --- a/lib/event-engine/presence/states/heartbeat_inactive.js +++ b/lib/event-engine/presence/states/heartbeat_inactive.js @@ -11,4 +11,3 @@ exports.HeartbeatInactiveState.on(events_1.joined.type, function (_, event) { groups: event.payload.groups, }); }); -exports.HeartbeatInactiveState.on(events_1.left.type, function (_, event) { return exports.HeartbeatInactiveState.with(); }); diff --git a/lib/event-engine/presence/states/heartbeat_reconnecting.js b/lib/event-engine/presence/states/heartbeat_reconnecting.js index e677bb017..1fb51af39 100644 --- a/lib/event-engine/presence/states/heartbeat_reconnecting.js +++ b/lib/event-engine/presence/states/heartbeat_reconnecting.js @@ -66,7 +66,7 @@ exports.HearbeatReconnectingState.on(events_1.disconnect.type, function (context groups: context.groups, }, [(0, effects_1.leave)(context.channels, context.groups)]); }); -exports.HearbeatReconnectingState.on(events_1.heartbeatSuccess.type, function (context, _) { +exports.HearbeatReconnectingState.on(events_1.heartbeatSuccess.type, function (context, event) { return heartbeat_cooldown_1.HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups, diff --git a/lib/event-engine/presence/states/heartbeat_stopped.js b/lib/event-engine/presence/states/heartbeat_stopped.js index 85aa8d718..6146a4266 100644 --- a/lib/event-engine/presence/states/heartbeat_stopped.js +++ b/lib/event-engine/presence/states/heartbeat_stopped.js @@ -27,7 +27,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { Object.defineProperty(exports, "__esModule", { value: true }); exports.HeartbeatStoppedState = void 0; var state_1 = require("../../core/state"); -var effects_1 = require("../effects"); var events_1 = require("../events"); var heartbeat_inactive_1 = require("./heartbeat_inactive"); var heartbeating_1 = require("./heartbeating"); @@ -42,7 +41,7 @@ exports.HeartbeatStoppedState.on(events_1.left.type, function (context, event) { return exports.HeartbeatStoppedState.with({ channels: context.channels.filter(function (channel) { return !event.payload.channels.includes(channel); }), groups: context.groups.filter(function (group) { return !event.payload.groups.includes(group); }), - }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); + }); }); exports.HeartbeatStoppedState.on(events_1.reconnect.type, function (context, _) { return heartbeating_1.HeartbeatingState.with({ @@ -50,12 +49,4 @@ exports.HeartbeatStoppedState.on(events_1.reconnect.type, function (context, _) groups: context.groups, }); }); -exports.HeartbeatStoppedState.on(events_1.disconnect.type, function (context, _) { - return exports.HeartbeatStoppedState.with({ - channels: context.channels, - groups: context.groups, - }, [(0, effects_1.leave)(context.channels, context.groups)]); -}); -exports.HeartbeatStoppedState.on(events_1.leftAll.type, function (context, _) { - return heartbeat_inactive_1.HeartbeatInactiveState.with(undefined, [(0, effects_1.leave)(context.channels, context.groups)]); -}); +exports.HeartbeatStoppedState.on(events_1.leftAll.type, function (context, _) { return heartbeat_inactive_1.HeartbeatInactiveState.with(undefined); }); diff --git a/lib/event-engine/presence/states/heartbeating.js b/lib/event-engine/presence/states/heartbeating.js index 176fb7663..675f30d64 100644 --- a/lib/event-engine/presence/states/heartbeating.js +++ b/lib/event-engine/presence/states/heartbeating.js @@ -50,7 +50,7 @@ exports.HeartbeatingState.on(events_1.heartbeatSuccess.type, function (context, return heartbeat_cooldown_1.HeartbeatCooldownState.with({ channels: context.channels, groups: context.groups, - }, [(0, effects_1.emitStatus)(event.payload)]); + }); }); exports.HeartbeatingState.on(events_1.joined.type, function (context, event) { return exports.HeartbeatingState.with({ @@ -65,7 +65,7 @@ exports.HeartbeatingState.on(events_1.left.type, function (context, event) { }, [(0, effects_1.leave)(event.payload.channels, event.payload.groups)]); }); exports.HeartbeatingState.on(events_1.heartbeatFailure.type, function (context, event) { - return heartbeat_reconnecting_1.HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload }), [(0, effects_1.emitStatus)(event.payload)]); + return heartbeat_reconnecting_1.HearbeatReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); }); exports.HeartbeatingState.on(events_1.disconnect.type, function (context) { return heartbeat_stopped_1.HeartbeatStoppedState.with({ diff --git a/lib/event-engine/states/handshake_failed.js b/lib/event-engine/states/handshake_failed.js new file mode 100644 index 000000000..a557af858 --- /dev/null +++ b/lib/event-engine/states/handshake_failed.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.HandshakeFailedState = void 0; +var state_1 = require("../core/state"); +var events_1 = require("../events"); +var handshaking_1 = require("./handshaking"); +var unsubscribed_1 = require("./unsubscribed"); +exports.HandshakeFailedState = new state_1.State('HANDSHAKE_FAILED'); +exports.HandshakeFailedState.on(events_1.subscriptionChange.type, function (_, event) { + return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); +}); +exports.HandshakeFailedState.on(events_1.reconnect.type, function (context, event) { + var _a, _b, _c, _d, _e; + return handshaking_1.HandshakingState.with({ + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: (_c = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.timetoken) !== null && _c !== void 0 ? _c : '0', + region: (_e = (_d = event.payload) === null || _d === void 0 ? void 0 : _d.region) !== null && _e !== void 0 ? _e : 0, + }, + }); +}); +exports.HandshakeFailedState.on(events_1.restore.type, function (_, event) { + var _a, _b; + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, + }); +}); +exports.HandshakeFailedState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(); }); diff --git a/lib/event-engine/states/handshake_reconnecting.js b/lib/event-engine/states/handshake_reconnecting.js index a050f3838..16c7a83b1 100644 --- a/lib/event-engine/states/handshake_reconnecting.js +++ b/lib/event-engine/states/handshake_reconnecting.js @@ -18,7 +18,7 @@ exports.HandshakeReconnectingState = void 0; var state_1 = require("../core/state"); var effects_1 = require("../effects"); var events_1 = require("../events"); -var handshake_failure_1 = require("./handshake_failure"); +var handshake_failed_1 = require("./handshake_failed"); var handshake_stopped_1 = require("./handshake_stopped"); var handshaking_1 = require("./handshaking"); var receiving_1 = require("./receiving"); @@ -27,36 +27,53 @@ var categories_1 = __importDefault(require("../../core/constants/categories")); exports.HandshakeReconnectingState = new state_1.State('HANDSHAKE_RECONNECTING'); exports.HandshakeReconnectingState.onEnter(function (context) { return (0, effects_1.handshakeReconnect)(context); }); exports.HandshakeReconnectingState.onExit(function () { return effects_1.handshakeReconnect.cancel; }); -exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingSuccess.type, function (context, event) { - var cursor = context.timetoken ? { timetoken: context.timetoken, region: 1 } : event.payload.cursor; +exports.HandshakeReconnectingState.on(events_1.handshakeReconnectSuccess.type, function (context, event) { + var _a; + var cursor = { + timetoken: (_a = context === null || context === void 0 ? void 0 : context.timetoken) !== null && _a !== void 0 ? _a : event.payload.cursor.timetoken, + region: event.payload.cursor.region, + }; return receiving_1.ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: cursor, }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectedCategory })]); }); -exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingFailure.type, function (context, event) { +exports.HandshakeReconnectingState.on(events_1.handshakeReconnectFailure.type, function (context, event) { return exports.HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); }); -exports.HandshakeReconnectingState.on(events_1.handshakingReconnectingGiveup.type, function (context) { - return handshake_failure_1.HandshakeFailureState.with({ +exports.HandshakeReconnectingState.on(events_1.handshakeReconnectGiveup.type, function (context, event) { + var _a; + return handshake_failed_1.HandshakeFailedState.with({ groups: context.groups, channels: context.channels, - reason: context.reason, - }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectionErrorCategory })]); + timetoken: context.timetoken, + reason: event.payload, + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectionErrorCategory, error: (_a = event.payload) === null || _a === void 0 ? void 0 : _a.message })]); }); exports.HandshakeReconnectingState.on(events_1.disconnect.type, function (context) { + var _a; return handshake_stopped_1.HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); + cursor: { + timetoken: (_a = context.timetoken) !== null && _a !== void 0 ? _a : '0', + region: 0 + } + }); }); exports.HandshakeReconnectingState.on(events_1.subscriptionChange.type, function (_, event) { return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); exports.HandshakeReconnectingState.on(events_1.restore.type, function (_, event) { - return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); -}); -exports.HandshakeReconnectingState.on(events_1.unsubscribeAll.type, function (_) { - return unsubscribed_1.UnsubscribedState.with(undefined, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); + var _a, _b; + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, + }); }); +exports.HandshakeReconnectingState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(undefined); }); diff --git a/lib/event-engine/states/handshake_stopped.js b/lib/event-engine/states/handshake_stopped.js index b799697d7..ef17507a3 100644 --- a/lib/event-engine/states/handshake_stopped.js +++ b/lib/event-engine/states/handshake_stopped.js @@ -15,11 +15,31 @@ exports.HandshakeStoppedState = void 0; var state_1 = require("../core/state"); var events_1 = require("../events"); var handshaking_1 = require("./handshaking"); +var unsubscribed_1 = require("./unsubscribed"); exports.HandshakeStoppedState = new state_1.State('HANDSHAKE_STOPPED'); -exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (_, event) { - return handshaking_1.HandshakingState.with({ +exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (context, event) { + return exports.HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, + cursor: context.cursor }); }); -exports.HandshakeStoppedState.on(events_1.reconnect.type, function (context) { return handshaking_1.HandshakingState.with(__assign({}, context)); }); +exports.HandshakeStoppedState.on(events_1.reconnect.type, function (context, event) { + var _a, _b, _c, _d, _e, _f; + return handshaking_1.HandshakingState.with(__assign(__assign({}, context), { cursor: { + timetoken: (_d = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : (_c = context.cursor) === null || _c === void 0 ? void 0 : _c.timetoken) !== null && _d !== void 0 ? _d : '0', + region: (_f = (_e = event.payload) === null || _e === void 0 ? void 0 : _e.region) !== null && _f !== void 0 ? _f : 0, + } })); +}); +exports.HandshakeStoppedState.on(events_1.restore.type, function (_, event) { + var _a, _b; + return exports.HandshakeStoppedState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, + }); +}); +exports.HandshakeStoppedState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(); }); diff --git a/lib/event-engine/states/handshaking.js b/lib/event-engine/states/handshaking.js index deccc6179..e6c123cd5 100644 --- a/lib/event-engine/states/handshaking.js +++ b/lib/event-engine/states/handshaking.js @@ -1,15 +1,4 @@ "use strict"; -var __assign = (this && this.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -32,18 +21,30 @@ exports.HandshakingState.on(events_1.subscriptionChange.type, function (context, } return exports.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); -exports.HandshakingState.on(events_1.handshakingSuccess.type, function (context, event) { +exports.HandshakingState.on(events_1.handshakeSuccess.type, function (context, event) { + var _a, _b; return receiving_1.ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: { - timetoken: context.timetoken && context.timetoken !== '0' ? context.timetoken : event.payload.timetoken, + timetoken: (_b = (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : event.payload.timetoken, region: event.payload.region, }, - }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectedCategory })]); + }, [ + (0, effects_1.emitStatus)({ + category: categories_1.default.PNConnectedCategory, + }), + ]); }); -exports.HandshakingState.on(events_1.handshakingFailure.type, function (context, event) { - return handshake_reconnecting_1.HandshakeReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); +exports.HandshakingState.on(events_1.handshakeFailure.type, function (context, event) { + var _a; + return handshake_reconnecting_1.HandshakeReconnectingState.with({ + channels: context.channels, + groups: context.groups, + timetoken: (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken, + attempts: 0, + reason: event.payload, + }); }); exports.HandshakingState.on(events_1.disconnect.type, function (context) { return handshake_stopped_1.HandshakeStoppedState.with({ @@ -51,11 +52,15 @@ exports.HandshakingState.on(events_1.disconnect.type, function (context) { groups: context.groups, }); }); -exports.HandshakingState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(); }); exports.HandshakingState.on(events_1.restore.type, function (_, event) { + var _a, _b; return exports.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, }); }); +exports.HandshakingState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(); }); diff --git a/lib/event-engine/states/receive_failed.js b/lib/event-engine/states/receive_failed.js new file mode 100644 index 000000000..b1473bf0d --- /dev/null +++ b/lib/event-engine/states/receive_failed.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ReceiveFailedState = void 0; +var state_1 = require("../core/state"); +var events_1 = require("../events"); +var handshaking_1 = require("./handshaking"); +var unsubscribed_1 = require("./unsubscribed"); +exports.ReceiveFailedState = new state_1.State('RECEIVE_FAILED'); +exports.ReceiveFailedState.on(events_1.reconnect.type, function (context, event) { + var _a, _b, _c, _d; + return handshaking_1.HandshakingState.with({ + channels: context.channels, + groups: context.groups, + cursor: { + timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : '0', + region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : 0, + }, + }); +}); +exports.ReceiveFailedState.on(events_1.subscriptionChange.type, function (_, event) { + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + }); +}); +exports.ReceiveFailedState.on(events_1.restore.type, function (_, event) { + var _a, _b; + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { timetoken: event.payload.timetoken, region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0 }, + }); +}); +exports.ReceiveFailedState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(undefined); }); diff --git a/lib/event-engine/states/receive_reconnecting.js b/lib/event-engine/states/receive_reconnecting.js index b7e0dc562..20877cc75 100644 --- a/lib/event-engine/states/receive_reconnecting.js +++ b/lib/event-engine/states/receive_reconnecting.js @@ -19,30 +19,31 @@ var state_1 = require("../core/state"); var effects_1 = require("../effects"); var events_1 = require("../events"); var receiving_1 = require("./receiving"); -var receive_failure_1 = require("./receive_failure"); +var receive_failed_1 = require("./receive_failed"); var receive_stopped_1 = require("./receive_stopped"); var unsubscribed_1 = require("./unsubscribed"); var categories_1 = __importDefault(require("../../core/constants/categories")); exports.ReceiveReconnectingState = new state_1.State('RECEIVE_RECONNECTING'); -exports.ReceiveReconnectingState.onEnter(function (context) { return (0, effects_1.reconnect)(context); }); -exports.ReceiveReconnectingState.onExit(function () { return effects_1.reconnect.cancel; }); -exports.ReceiveReconnectingState.on(events_1.reconnectingSuccess.type, function (context, event) { +exports.ReceiveReconnectingState.onEnter(function (context) { return (0, effects_1.receiveReconnect)(context); }); +exports.ReceiveReconnectingState.onExit(function () { return effects_1.receiveReconnect.cancel; }); +exports.ReceiveReconnectingState.on(events_1.receiveReconnectSuccess.type, function (context, event) { return receiving_1.ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor, - }, [(0, effects_1.emitEvents)(event.payload.events)]); + }, [(0, effects_1.emitMessages)(event.payload.events)]); }); -exports.ReceiveReconnectingState.on(events_1.reconnectingFailure.type, function (context, event) { +exports.ReceiveReconnectingState.on(events_1.receiveReconnectFailure.type, function (context, event) { return exports.ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: context.attempts + 1, reason: event.payload })); }); -exports.ReceiveReconnectingState.on(events_1.reconnectingGiveup.type, function (context) { - return receive_failure_1.ReceiveFailureState.with({ +exports.ReceiveReconnectingState.on(events_1.receiveReconnectGiveup.type, function (context, event) { + var _a; + return receive_failed_1.ReceiveFailedState.with({ groups: context.groups, channels: context.channels, cursor: context.cursor, - reason: context.reason, - }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedUnexpectedlyCategory })]); + reason: event.payload, + }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedUnexpectedlyCategory, error: (_a = event.payload) === null || _a === void 0 ? void 0 : _a.message })]); }); exports.ReceiveReconnectingState.on(events_1.disconnect.type, function (context) { return receive_stopped_1.ReceiveStoppedState.with({ @@ -57,8 +58,8 @@ exports.ReceiveReconnectingState.on(events_1.restore.type, function (context, ev channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: (_a = event.payload.timetoken) !== null && _a !== void 0 ? _a : context.cursor.timetoken, - region: (_b = event.payload.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, }, }); }); diff --git a/lib/event-engine/states/receive_stopped.js b/lib/event-engine/states/receive_stopped.js index f8d340e42..370f96752 100644 --- a/lib/event-engine/states/receive_stopped.js +++ b/lib/event-engine/states/receive_stopped.js @@ -4,27 +4,35 @@ exports.ReceiveStoppedState = void 0; var state_1 = require("../core/state"); var events_1 = require("../events"); var handshaking_1 = require("./handshaking"); -var receiving_1 = require("./receiving"); var unsubscribed_1 = require("./unsubscribed"); -exports.ReceiveStoppedState = new state_1.State('STOPPED'); +exports.ReceiveStoppedState = new state_1.State('RECEIVE_STOPPED'); exports.ReceiveStoppedState.on(events_1.subscriptionChange.type, function (context, event) { - return receiving_1.ReceivingState.with({ + return exports.ReceiveStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: context.cursor, }); }); exports.ReceiveStoppedState.on(events_1.restore.type, function (context, event) { - return receiving_1.ReceivingState.with({ + var _a, _b; + return exports.ReceiveStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region + }, }); }); -exports.ReceiveStoppedState.on(events_1.reconnect.type, function (context) { +exports.ReceiveStoppedState.on(events_1.reconnect.type, function (context, event) { + var _a, _b, _c, _d; return handshaking_1.HandshakingState.with({ channels: context.channels, groups: context.groups, + cursor: { + timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.cursor.timetoken, + region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : context.cursor.region, + }, }); }); exports.ReceiveStoppedState.on(events_1.unsubscribeAll.type, function () { return unsubscribed_1.UnsubscribedState.with(undefined); }); diff --git a/lib/event-engine/states/receiving.js b/lib/event-engine/states/receiving.js index 5124c564b..ba951310b 100644 --- a/lib/event-engine/states/receiving.js +++ b/lib/event-engine/states/receiving.js @@ -23,11 +23,11 @@ var receive_reconnecting_1 = require("./receive_reconnecting"); var receive_stopped_1 = require("./receive_stopped"); var categories_1 = __importDefault(require("../../core/constants/categories")); exports.ReceivingState = new state_1.State('RECEIVING'); -exports.ReceivingState.onEnter(function (context) { return (0, effects_1.receiveEvents)(context.channels, context.groups, context.cursor); }); -exports.ReceivingState.onExit(function () { return effects_1.receiveEvents.cancel; }); -exports.ReceivingState.on(events_1.receivingSuccess.type, function (context, event) { +exports.ReceivingState.onEnter(function (context) { return (0, effects_1.receiveMessages)(context.channels, context.groups, context.cursor); }); +exports.ReceivingState.onExit(function () { return effects_1.receiveMessages.cancel; }); +exports.ReceivingState.on(events_1.receiveSuccess.type, function (context, event) { return exports.ReceivingState.with({ channels: context.channels, groups: context.groups, cursor: event.payload.cursor }, [ - (0, effects_1.emitEvents)(event.payload.events), + (0, effects_1.emitMessages)(event.payload.events), ]); }); exports.ReceivingState.on(events_1.subscriptionChange.type, function (context, event) { @@ -40,7 +40,21 @@ exports.ReceivingState.on(events_1.subscriptionChange.type, function (context, e groups: event.payload.groups, }); }); -exports.ReceivingState.on(events_1.receivingFailure.type, function (context, event) { +exports.ReceivingState.on(events_1.restore.type, function (context, event) { + var _a, _b; + if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { + return unsubscribed_1.UnsubscribedState.with(undefined); + } + return exports.ReceivingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + }, + }); +}); +exports.ReceivingState.on(events_1.receiveFailure.type, function (context, event) { return receive_reconnecting_1.ReceiveReconnectingState.with(__assign(__assign({}, context), { attempts: 0, reason: event.payload })); }); exports.ReceivingState.on(events_1.disconnect.type, function (context) { diff --git a/lib/event-engine/states/unsubscribed.js b/lib/event-engine/states/unsubscribed.js index 40398b038..90debb100 100644 --- a/lib/event-engine/states/unsubscribed.js +++ b/lib/event-engine/states/unsubscribed.js @@ -9,13 +9,16 @@ exports.UnsubscribedState.on(events_1.subscriptionChange.type, function (_, even return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, }); }); exports.UnsubscribedState.on(events_1.restore.type, function (_, event) { + var _a, _b; return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - timetoken: event.payload.timetoken, + cursor: { + timetoken: event.payload.timetoken, + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + }, }); }); diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 27a2c699e..62bd1b7da 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -404,7 +404,6 @@ export default class { this.disconnect = eventEngine.disconnect.bind(eventEngine); this.destroy = eventEngine.dispose.bind(eventEngine); this.eventEngine = eventEngine; - } else { const subscriptionManager = new SubscriptionManager({ timeEndpoint, diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index a08996455..0f0e0263d 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -97,7 +97,7 @@ export class EventEngine { } } - reconnect({timetoken, region } : {timetoken?:string, region?: number}) { + reconnect({ timetoken, region }: { timetoken?: string; region?: number }) { this.engine.transition(events.reconnect(timetoken, region)); } diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index f8ac98917..063146fb5 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -71,8 +71,8 @@ HandshakeReconnectingState.on(disconnect.type, (context) => groups: context.groups, cursor: { timetoken: context.timetoken ?? '0', - region: 0 - } + region: 0, + }, }), ); diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index 344721395..2e132aa97 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -17,7 +17,7 @@ HandshakeStoppedState.on(subscriptionChange.type, (context, event) => HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor + cursor: context.cursor, }), ); diff --git a/src/event-engine/states/receive_stopped.ts b/src/event-engine/states/receive_stopped.ts index 7879369fd..ce75c3b7f 100644 --- a/src/event-engine/states/receive_stopped.ts +++ b/src/event-engine/states/receive_stopped.ts @@ -27,7 +27,7 @@ ReceiveStoppedState.on(restore.type, (context, event) => groups: event.payload.groups, cursor: { timetoken: event.payload.timetoken, - region: event.payload?.region ?? context.cursor.region + region: event.payload?.region ?? context.cursor.region, }, }), ); From c35559fef8bfb49b63d334fd42fb3733f36c75bd Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Thu, 11 Jan 2024 14:40:34 +0530 Subject: [PATCH 44/63] package-lock dependabot suggestion, fix test --- package-lock.json | 12 ++++++------ test/unit/event_engine_presence.test.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index cf6948618..c11314d98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3427,9 +3427,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.4", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", + "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", "dev": true, "funding": [ { @@ -10526,9 +10526,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.4", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", + "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", "dev": true }, "forever-agent": { diff --git a/test/unit/event_engine_presence.test.ts b/test/unit/event_engine_presence.test.ts index 894f69c51..432886e45 100644 --- a/test/unit/event_engine_presence.test.ts +++ b/test/unit/event_engine_presence.test.ts @@ -116,7 +116,7 @@ describe('EventEngine', () => { await forEvent('HEARTBEAT_SUCCESS', 1000); - await forState('HEARTBEATCOOLDOWN', 1000); + await forState('HEARTBEAT_COOLDOWN', 1000); pubnub.leaveAll(); From b4db5b5edaaab079e540e5ef12d9e91471e44afa Mon Sep 17 00:00:00 2001 From: Mohit Tejani <60129002+mohitpubnub@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:19:04 +0530 Subject: [PATCH 45/63] removed duplicate file --- .../NodeCryptoModule/NodeCryptoModule.js | 446 ------------------ 1 file changed, 446 deletions(-) delete mode 100644 lib/crypto/modules/NodeCryptoModule/NodeCryptoModule.js diff --git a/lib/crypto/modules/NodeCryptoModule/NodeCryptoModule.js b/lib/crypto/modules/NodeCryptoModule/NodeCryptoModule.js deleted file mode 100644 index fdaef2d94..000000000 --- a/lib/crypto/modules/NodeCryptoModule/NodeCryptoModule.js +++ /dev/null @@ -1,446 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.CryptoModule = exports.AesCbcCryptor = exports.LegacyCryptor = void 0; -var stream_1 = require("stream"); -var base64_codec_1 = require("../../../core/components/base64_codec"); -var legacyCryptor_1 = __importDefault(require("./legacyCryptor")); -exports.LegacyCryptor = legacyCryptor_1.default; -var aesCbcCryptor_1 = __importDefault(require("./aesCbcCryptor")); -exports.AesCbcCryptor = aesCbcCryptor_1.default; -var CryptoModule = /** @class */ (function () { - function CryptoModule(cryptoModuleConfiguration) { - var _a; - this.defaultCryptor = cryptoModuleConfiguration.default; - this.cryptors = (_a = cryptoModuleConfiguration.cryptors) !== null && _a !== void 0 ? _a : []; - } - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: type detection issue with old Config type assignment - CryptoModule.legacyCryptoModule = function (config) { - var _a; - return new this({ - default: new legacyCryptor_1.default({ - cipherKey: config.cipherKey, - useRandomIVs: (_a = config.useRandomIVs) !== null && _a !== void 0 ? _a : true, - }), - cryptors: [new aesCbcCryptor_1.default({ cipherKey: config.cipherKey })], - }); - }; - CryptoModule.aesCbcCryptoModule = function (config) { - var _a; - return new this({ - default: new aesCbcCryptor_1.default({ cipherKey: config.cipherKey }), - cryptors: [ - new legacyCryptor_1.default({ - cipherKey: config.cipherKey, - useRandomIVs: (_a = config.useRandomIVs) !== null && _a !== void 0 ? _a : true, - }), - ], - }); - }; - CryptoModule.withDefaultCryptor = function (defaultCryptor) { - return new this({ default: defaultCryptor }); - }; - CryptoModule.prototype.getAllCryptors = function () { - return __spreadArray([this.defaultCryptor], __read(this.cryptors), false); - }; - CryptoModule.prototype.getLegacyCryptor = function () { - return this.getAllCryptors().find(function (c) { return c.identifier === ''; }); - }; - CryptoModule.prototype.encrypt = function (data) { - var encrypted = this.defaultCryptor.encrypt(data); - if (!encrypted.metadata) - return encrypted.data; - var header = CryptorHeader.from(this.defaultCryptor.identifier, encrypted.metadata); - var headerData = new Uint8Array(header.length); - var pos = 0; - headerData.set(header.data, pos); - pos = header.length - encrypted.metadata.length; - headerData.set(encrypted.metadata, pos); - return Buffer.concat([headerData, Buffer.from(encrypted.data)]); - }; - CryptoModule.prototype.decrypt = function (data) { - var encryptedData = Buffer.from(typeof data === 'string' ? (0, base64_codec_1.decode)(data) : data); - var header = CryptorHeader.tryParse(encryptedData); - var cryptor = this.getCryptor(header); - var metadata = header.length > 0 - ? encryptedData.slice(header.length - header.metadataLength, header.length) - : null; - if (encryptedData.slice(header.length).byteLength <= 0) - throw new Error('decryption error. empty content'); - return cryptor.decrypt({ - data: encryptedData.slice(header.length), - metadata: metadata, - }); - }; - CryptoModule.prototype.encryptFile = function (file, File) { - return __awaiter(this, void 0, void 0, function () { - var encryptedStream, header, payload, pos, output; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - /** - * Files handled differently in case of Legacy cryptor. - * (as long as we support legacy need to check on intsance type) - */ - if (this.defaultCryptor.identifier === CryptorHeader.LEGACY_IDENTIFIER) - return [2 /*return*/, this.defaultCryptor.encryptFile(file, File)]; - if (file.data instanceof Buffer) { - return [2 /*return*/, File.create({ - name: file.name, - mimeType: 'application/octet-stream', - data: Buffer.from(this.encrypt(file.data)), - })]; - } - if (!(file.data instanceof stream_1.Readable)) return [3 /*break*/, 2]; - if (file.contentLength === 0) - throw new Error('encryption error. empty content'); - return [4 /*yield*/, this.defaultCryptor.encryptStream(file.data)]; - case 1: - encryptedStream = _a.sent(); - header = CryptorHeader.from(this.defaultCryptor.identifier, encryptedStream.metadata); - payload = new Uint8Array(header.length); - pos = 0; - payload.set(header.data, pos); - pos += header.length; - if (encryptedStream.metadata) { - pos -= encryptedStream.metadata.length; - payload.set(encryptedStream.metadata, pos); - } - output = new stream_1.PassThrough(); - output.write(payload); - encryptedStream.stream.pipe(output); - return [2 /*return*/, File.create({ - name: file.name, - mimeType: 'application/octet-stream', - stream: output, - })]; - case 2: return [2 /*return*/]; - } - }); - }); - }; - CryptoModule.prototype.decryptFile = function (file, File) { - return __awaiter(this, void 0, void 0, function () { - var header, cryptor, stream_2; - var _this = this; - return __generator(this, function (_a) { - if ((file === null || file === void 0 ? void 0 : file.data) instanceof Buffer) { - header = CryptorHeader.tryParse(file.data); - cryptor = this.getCryptor(header); - /** - * If It's legacyone then redirect it. - * (as long as we support legacy need to check on instance type) - */ - if ((cryptor === null || cryptor === void 0 ? void 0 : cryptor.identifier) === CryptoModule.LEGACY_IDENTIFIER) - return [2 /*return*/, cryptor.decryptFile(file, File)]; - return [2 /*return*/, File.create({ - name: file.name, - data: Buffer.from(this.decrypt(file === null || file === void 0 ? void 0 : file.data)), - })]; - } - if (file.data instanceof stream_1.Readable) { - stream_2 = file.data; - return [2 /*return*/, new Promise(function (resolve) { - stream_2.on('readable', function () { return resolve(_this.onStreamReadable(stream_2, file, File)); }); - })]; - } - return [2 /*return*/]; - }); - }); - }; - CryptoModule.prototype.onStreamReadable = function (stream, file, File) { - return __awaiter(this, void 0, void 0, function () { - var magicBytes, versionByte, identifier, cryptor, headerSize, _a, _b; - var _c; - return __generator(this, function (_d) { - switch (_d.label) { - case 0: - stream.removeAllListeners('readable'); - magicBytes = stream.read(4); - if (!CryptorHeader.isSentinel(magicBytes)) { - if (magicBytes === null) - throw new Error('decryption error. empty content'); - stream.unshift(magicBytes); - return [2 /*return*/, this.decryptLegacyFileStream(stream, file, File)]; - } - versionByte = stream.read(1); - CryptorHeader.validateVersion(versionByte[0]); - identifier = stream.read(4); - cryptor = this.getCryptorFromId(CryptorHeader.tryGetIdentifier(identifier)); - headerSize = CryptorHeader.tryGetMetadataSizeFromStream(stream); - if (file.contentLength <= CryptorHeader.MIN_HEADER_LEGTH + headerSize) - throw new Error('decryption error. empty content'); - _b = (_a = File).create; - _c = { - name: file.name, - mimeType: 'application/octet-stream' - }; - return [4 /*yield*/, cryptor.decryptStream({ stream: stream, metadataLength: headerSize })]; - case 1: return [2 /*return*/, _b.apply(_a, [(_c.stream = _d.sent(), - _c)])]; - } - }); - }); - }; - CryptoModule.prototype.decryptLegacyFileStream = function (stream, file, File) { - return __awaiter(this, void 0, void 0, function () { - var cryptor; - return __generator(this, function (_a) { - if (file.contentLength <= 16) - throw new Error('decryption error: empty content'); - cryptor = this.getLegacyCryptor(); - if (cryptor) { - return [2 /*return*/, cryptor.decryptFile(File.create({ - name: file.name, - stream: stream, - }), File)]; - } - else { - throw new Error('unknown cryptor error'); - } - return [2 /*return*/]; - }); - }); - }; - CryptoModule.prototype.getCryptor = function (header) { - if (header === '') { - var cryptor = this.getAllCryptors().find(function (c) { return c.identifier === ''; }); - if (cryptor) - return cryptor; - throw new Error('unknown cryptor error'); - } - else if (header instanceof CryptorHeaderV1) { - return this.getCryptorFromId(header.identifier); - } - }; - CryptoModule.prototype.getCryptorFromId = function (id) { - var cryptor = this.getAllCryptors().find(function (c) { return id === c.identifier; }); - if (cryptor) { - return cryptor; - } - throw new Error('unknown cryptor error'); - }; - CryptoModule.LEGACY_IDENTIFIER = ''; - return CryptoModule; -}()); -exports.CryptoModule = CryptoModule; -// CryptorHeader Utility -var CryptorHeader = /** @class */ (function () { - function CryptorHeader() { - } - CryptorHeader.from = function (id, metadata) { - if (id === CryptorHeader.LEGACY_IDENTIFIER) - return; - return new CryptorHeaderV1(id, metadata.length); - }; - CryptorHeader.isSentinel = function (bytes) { - if (bytes && bytes.byteLength >= 4) { - if (bytes.toString('utf8') == CryptorHeader.SENTINEL) - return true; - } - }; - CryptorHeader.validateVersion = function (data) { - if (data && data > CryptorHeader.MAX_VERSION) - throw new Error('decryption error. invalid header version'); - return data; - }; - CryptorHeader.tryGetIdentifier = function (data) { - if (data.byteLength < 4) { - throw new Error('unknown cryptor error. decryption failed'); - } - else { - return data.toString('utf8'); - } - }; - CryptorHeader.tryGetMetadataSizeFromStream = function (stream) { - var sizeBuf = stream.read(1); - if (sizeBuf && sizeBuf[0] < 255) { - return sizeBuf[0]; - } - if (sizeBuf[0] === 255) { - var nextBuf = stream.read(2); - if (nextBuf.length >= 2) { - return new Uint16Array([nextBuf[0], nextBuf[1]]).reduce(function (acc, val) { return (acc << 8) + val; }, 0); - } - } - throw new Error('decryption error. Invalid metadata size'); - }; - CryptorHeader.tryParse = function (encryptedData) { - var sentinel = ''; - var version = null; - if (encryptedData.length >= 4) { - sentinel = encryptedData.slice(0, 4); - if (sentinel.toString('utf8') !== CryptorHeader.SENTINEL) - return ''; - } - if (encryptedData.length >= 5) { - version = encryptedData[4]; - } - else { - throw new Error('decryption error. invalid header version'); - } - if (version > CryptorHeader.MAX_VERSION) - throw new Error('unknown cryptor error'); - var identifier; - var pos = 5 + CryptorHeader.IDENTIFIER_LENGTH; - if (encryptedData.length >= pos) { - identifier = encryptedData.slice(5, pos); - } - else { - throw new Error('decryption error. invalid crypto identifier'); - } - var metadataLength = null; - if (encryptedData.length >= pos + 1) { - metadataLength = encryptedData[pos]; - } - else { - throw new Error('decryption error. invalid metadata length'); - } - pos += 1; - if (metadataLength === 255 && encryptedData.length >= pos + 2) { - metadataLength = new Uint16Array(encryptedData.slice(pos, pos + 2)).reduce(function (acc, val) { return (acc << 8) + val; }, 0); - pos += 2; - } - return new CryptorHeaderV1(identifier.toString('utf8'), metadataLength); - }; - CryptorHeader.SENTINEL = 'PNED'; - CryptorHeader.LEGACY_IDENTIFIER = ''; - CryptorHeader.IDENTIFIER_LENGTH = 4; - CryptorHeader.VERSION = 1; - CryptorHeader.MAX_VERSION = 1; - CryptorHeader.MIN_HEADER_LEGTH = 10; - return CryptorHeader; -}()); -// v1 CryptorHeader -var CryptorHeaderV1 = /** @class */ (function () { - function CryptorHeaderV1(id, metadataLength) { - this._identifier = id; - this._metadataLength = metadataLength; - } - Object.defineProperty(CryptorHeaderV1.prototype, "identifier", { - get: function () { - return this._identifier; - }, - set: function (value) { - this._identifier = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(CryptorHeaderV1.prototype, "metadataLength", { - get: function () { - return this._metadataLength; - }, - set: function (value) { - this._metadataLength = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(CryptorHeaderV1.prototype, "version", { - get: function () { - return CryptorHeader.VERSION; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(CryptorHeaderV1.prototype, "length", { - get: function () { - return (CryptorHeader.SENTINEL.length + - 1 + - CryptorHeader.IDENTIFIER_LENGTH + - (this.metadataLength < 255 ? 1 : 3) + - this.metadataLength); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(CryptorHeaderV1.prototype, "data", { - get: function () { - var pos = 0; - var header = new Uint8Array(this.length); - header.set(Buffer.from(CryptorHeader.SENTINEL)); - pos += CryptorHeader.SENTINEL.length; - header[pos] = this.version; - pos++; - if (this.identifier) - header.set(Buffer.from(this.identifier), pos); - pos += CryptorHeader.IDENTIFIER_LENGTH; - var metadataLength = this.metadataLength; - if (metadataLength < 255) { - header[pos] = metadataLength; - } - else { - header.set([255, metadataLength >> 8, metadataLength & 0xff], pos); - } - return header; - }, - enumerable: false, - configurable: true - }); - return CryptorHeaderV1; -}()); From f46818fd962e1942eab7c95a8f7dfa218e394d86 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 12 Jan 2024 17:12:01 +0530 Subject: [PATCH 46/63] fix: prevent duplicate listener to be added. --- src/core/components/listener_manager.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/components/listener_manager.js b/src/core/components/listener_manager.js index 4b7a2d207..fb41c1f2d 100644 --- a/src/core/components/listener_manager.js +++ b/src/core/components/listener_manager.js @@ -7,8 +7,11 @@ export default class { this._listeners = []; } - addListener(newListeners) { - this._listeners.push(newListeners); + addListener(newListener) { + if (this._listeners.includes(newListener)) { + return; + } + this._listeners.push(newListener); } removeListener(deprecatedListener) { From 5389aafc6dcd0be06a4927d27667649efe2daba7 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Fri, 12 Jan 2024 17:14:53 +0530 Subject: [PATCH 47/63] dist/lib files --- dist/web/pubnub.js | 15 +++++++++------ dist/web/pubnub.min.js | 2 +- lib/core/components/listener_manager.js | 7 +++++-- lib/event-engine/states/handshake_reconnecting.js | 4 ++-- lib/event-engine/states/handshake_stopped.js | 2 +- lib/event-engine/states/receive_stopped.js | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index c56ee50fd..b718062eb 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -3222,8 +3222,11 @@ function default_1() { this._listeners = []; } - default_1.prototype.addListener = function (newListeners) { - this._listeners.push(newListeners); + default_1.prototype.addListener = function (newListener) { + if (this._listeners.includes(newListener)) { + return; + } + this._listeners.push(newListener); }; default_1.prototype.removeListener = function (deprecatedListener) { var newListeners = []; @@ -7409,7 +7412,7 @@ return HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor + cursor: context.cursor, }); }); HandshakeStoppedState.on(reconnect$1.type, function (context, event) { @@ -7475,7 +7478,7 @@ groups: event.payload.groups, cursor: { timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, }, }); }); @@ -7623,8 +7626,8 @@ groups: context.groups, cursor: { timetoken: (_a = context.timetoken) !== null && _a !== void 0 ? _a : '0', - region: 0 - } + region: 0, + }, }); }); HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 308a7e60a..83fc694da 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -14,4 +14,4 @@ PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return d(3,o.length),p(o);default:var f;if(Array.isArray(t))for(d(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var v=function e(){var o,d,v=l(),m=v>>5,b=31&v;if(7===m)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((d=h(b))<0&&(m<2||6=0;)S+=d,_.push(c(d));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(d);case 3:var P=[];if(d<0)for(;(d=y(m))>=0;)g(P,d);else g(P,d);return String.fromCharCode.apply(null,P);case 4:var E;if(d<0)for(E=[];!f();)E.push(e());else for(E=new Array(d),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function v(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,h=(3&l)<<6|p>>0;o[s]=d,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=h)}return r}function m(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),d=2;d<=p;d++)if(!(l%d)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],d=0;64>d;d++){if(16>d)f[d]=0|e[t+d];else{var h=f[d-15],y=f[d-2];f[d]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+f[d-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[d-16]}h=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[d]+f[d],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+h|0,s=i,i=o,o=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],d=e[i+4],f=e[i+5],h=e[i+6],y=e[i+7],g=e[i+8],v=e[i+9],m=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,d,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,h,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,v,12,c[9]),T=t(T,E,P,A,m,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,h,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,m,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,d,20,c[23]),P=n(P,A,T,E,v,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,d,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,m,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,h,23,c[43]),P=r(P,A,T,E,v,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,m,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,h,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,d,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,v,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),d=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},h=t.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=d.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],d=[],f=[],h=0;256>h;h++)f[h]=128>h?h<<1:h<<1^283;var y=0,g=0;for(h=0;256>h;h++){var v=(v=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&v^99;r[y]=v,o[v]=y;var m=f[y],b=f[m],_=f[b],S=257*f[v]^16843008*v;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*m^16843008*y,c[v]=S<<24|S>>>8,l[v]=S<<16|S>>>16,p[v]=S<<8|S>>>24,d[v]=S,y?(y=m^f[f[f[_^m]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^d[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,d,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],d=e[t+3]^n[3],f=4,h=1;h>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&d]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[d>>>8&255]^a[255&c]^n[f++],v=r[p>>>24]^o[d>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];d=r[d>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=v}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&d])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[d>>>8&255]<<8|s[255&c])^n[f++],v=(s[p>>>24]<<24|s[d>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],d=(s[d>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=v,e[t+3]=d},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,d=r(u,["uuid","channel"]);d.user=l,d.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:d})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var h=void 0;try{h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){h=void 0;try{var g;h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=h?h:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,d=i.length>0;(l||p||d)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),d&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,h=s.length>0,y=u.length>0;return(f||h||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),h&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ve={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},me=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,d=e.file,f=e.message,h=e.cipherKey,y=e.meta,g=e.ttl,v=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,m,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!d)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(d),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,m=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(h||l)?null!=h?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(h,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&d.uri?(A=(T=p).POSTFILE,k=[m,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[m,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[m,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[m,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:v,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&v.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&v.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&v.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&v.include.push("uuid.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&d.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&d.include.push("uuid")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&v.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&v.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&v.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&v.include.push("channel.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,d=void 0!==p&&p,f=t.manage,h=void 0!==f&&f,y=t.get,g=void 0!==y&&y,v=t.join,m=void 0!==v&&v,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=d?"1":"0",P.m=h?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=m?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,d=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,d=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),d=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),h=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||h||d||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,d=t.includeUUID,f=void 0===d||d,h=t.includeMessageType,y=void 0===h||h,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],d=l[1],f=l[2];try{for(var h=a(this.currentState.exitEffects),y=h.next();!y.done;y=h.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var m=this.currentContext;this.currentContext=d,this.notify({type:"transitionDone",fromState:v,fromContext:m,toState:p,toContext:d,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&a(e),[2]}))}))}))),r.on(dt.type,ut((function(e,t,n){var a=n.emitStatus;return o(r,void 0,void 0,(function(){return i(this,(function(t){return a(e),[2]}))}))}))),r.on(ft.type,ut((function(e,n,a){var s=a.receiveMessages,u=a.delay,c=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r.on(ht.type,ut((function(e,n,a){var s=a.handshake,u=a.delay,c=a.presenceState,l=a.config;return o(r,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={abortSignal:n,channels:e.channels,channelGroups:e.groups,filterExpression:l.filterExpression},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(l.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r}return t(n,e),n}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){var n,r,o,i,a;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(o=null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.timetoken)&&void 0!==o?o:"0",region:null!==(a=null===(i=t.payload)||void 0===i?void 0:i.region)&&void 0!==a?a:0}})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){var r,o,i,a,s,u;return Ft.with(n(n({},e),{cursor:{timetoken:null!==(a=null!==(o=null===(r=t.payload)||void 0===r?void 0:r.timetoken)&&void 0!==o?o:null===(i=e.cursor)||void 0===i?void 0:i.timetoken)&&void 0!==a?a:"0",region:null!==(u=null===(s=t.payload)||void 0===s?void 0:s.region)&&void 0!==u?u:0}}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:"0",region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:0}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){var n,r;return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.cursor.timetoken,region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[dt({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){var n,r;return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){var n,r;return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ht(e)})),Dt.onExit((function(){return ht.cancel})),Dt.on(bt.type,(function(e,t){var n,r={timetoken:null!==(n=null==e?void 0:e.timetoken)&&void 0!==n?n:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:r},[dt({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,timetoken:e.timetoken,reason:t.payload},[dt({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){var t;return jt.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(t=e.timetoken)&&void 0!==t?t:"0",region:0}})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(vt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=e.cursor)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:t.payload.timetoken,region:t.payload.region}},[dt({category:R.PNConnectedCategory})])})),Ft.on(mt.type,(function(e,t){var n;return Dt.with({channels:e.channels,groups:e.groups,timetoken:null===(n=e.cursor)||void 0===n?void 0:n.timetoken,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,n,r){var s=r.heartbeat,u=r.presenceState,c=r.config;return o(a,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),n={channels:e.channels,channelGroups:e.groups},c.maintainPresenceState&&(n.state=u),[4,s(n)];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,n,r){var s=r.heartbeat,u=r.retryDelay,c=r.presenceState,l=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(t){return{delay:t.delay,maximumRetry:t.maximumRetry,shouldRetry:function(t,n){var r;return!e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)&&this.maximumRetry>n},getDelay:function(e){return 1e3*(this.delay+Math.random())},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.ExponentialRetryPolicy=function(t){return{minimumDelay:t.minimumDelay,maximumDelay:t.maximumDelay,maximumRetry:t.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){var t=1e3*(Math.pow(2,e)+Math.random());return t>this.maximumDelay?this.maximumDelay:t},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.excludedErrorCodes=[403,429],e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var d=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(d=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=d.message,a.file={id:d.file.id,name:d.file.name,url:this.getFileUrl({id:d.file.id,name:d.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var h;f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),dn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var d=new I({maximumSamplesCount:6e4});this._telemetryManager=d;var f=this._config.cryptoModule,h={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:d,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,h,Je),v=Q.bind(this,h,ae),b=Q.bind(this,h,ue),_=Q.bind(this,h,le),S=Q.bind(this,h,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,h,ue),this.iAmAway=Q.bind(this,h,ae),this.setPresenceState=Q.bind(this,h,le),this.handshake=Q.bind(this,h,Qe),this.receiveMessages=Q.bind(this,h,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:h,listenerManager:this._listenerManager,getFileUrl:function(e){return be(h,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*h.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:h.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:h.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:h.crypto,config:h.config,listenerManager:w,getFileUrl:function(e){return be(h,e)},cryptoModule:h.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,h,ee),listChannels:Q.bind(this,h,te),addChannels:Q.bind(this,h,X),removeChannels:Q.bind(this,h,Y),deleteGroup:Q.bind(this,h,Z)},this.push={addChannels:Q.bind(this,h,ne),removeChannels:Q.bind(this,h,re),deleteDevice:Q.bind(this,h,ie),listChannels:Q.bind(this,h,oe)},this.hereNow=Q.bind(this,h,pe),this.whereNow=Q.bind(this,h,se),this.getState=Q.bind(this,h,ce),this.grant=Q.bind(this,h,Ue),this.grantToken=Q.bind(this,h,Ge),this.audit=Q.bind(this,h,xe),this.revokeToken=Q.bind(this,h,Le),this.publish=Q.bind(this,h,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,h,He),this.history=Q.bind(this,h,qe),this.deleteMessages=Q.bind(this,h,ze),this.messageCounts=Q.bind(this,h,Ve),this.fetchMessages=Q.bind(this,h,We),this.addMessageAction=Q.bind(this,h,de),this.removeMessageAction=Q.bind(this,h,fe),this.getMessageActions=Q.bind(this,h,he),this.listFiles=Q.bind(this,h,ye);var T=Q.bind(this,h,ge);this.publishFile=Q.bind(this,h,ve),this.sendFile=me({generateUploadUrl:T,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return be(h,e)},this.downloadFile=Q.bind(this,h,_e),this.deleteFile=Q.bind(this,h,Se),this.objects={getAllUUIDMetadata:Q.bind(this,h,we),getUUIDMetadata:Q.bind(this,h,Oe),setUUIDMetadata:Q.bind(this,h,Pe),removeUUIDMetadata:Q.bind(this,h,Ee),getAllChannelMetadata:Q.bind(this,h,Te),getChannelMetadata:Q.bind(this,h,Ae),setChannelMetadata:Q.bind(this,h,ke),removeChannelMetadata:Q.bind(this,h,Ce),getChannelMembers:Q.bind(this,h,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function hn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?hn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},vn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var h=zn(a,p);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},dr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(dr);var fr=pr,hr=dr.exports,yr=hr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),vr="function"==typeof Map&&Map.prototype,mr=Object.getOwnPropertyDescriptor&&vr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=vr&&mr&&"function"==typeof mr.get?mr.get:null,_r=vr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?hr(n):n},vo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var d=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var h=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,f);return"[Function"+(h?": "+h:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var v="<"+Ur.call(String(t.nodeName)),m=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,f);return d&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,d)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,d)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,d)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":d?k+"{"+fo(P,d)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},mo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?m.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(m);O=c?E.sort(c):E}for(var T=o&&Ho(m)&&1===m.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+d:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const di=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&di.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const hi=ai;var yi=gi;function gi(){}function vi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function mi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function v(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&m(t,n,e[n]);return t.join("&")}function m(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){m(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&m(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=v,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,d.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=v(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||h,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:m(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:v(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return hn(d.decode(e))}),v),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(dn);return Bi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(f,f.exports);var h=f.exports,y=function(){return h.uuid?h.uuid():h()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function v(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,h=(3&l)<<6|p>>0;o[s]=d,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=h)}return r}function m(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),d=2;d<=p;d++)if(!(l%d)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],d=0;64>d;d++){if(16>d)f[d]=0|e[t+d];else{var h=f[d-15],y=f[d-2];f[d]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+f[d-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[d-16]}h=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[d]+f[d],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+h|0,s=i,i=o,o=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],d=e[i+4],f=e[i+5],h=e[i+6],y=e[i+7],g=e[i+8],v=e[i+9],m=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,d,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,h,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,v,12,c[9]),T=t(T,E,P,A,m,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,h,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,m,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,d,20,c[23]),P=n(P,A,T,E,v,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,d,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,m,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,h,23,c[43]),P=r(P,A,T,E,v,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,m,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,h,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,d,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,v,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),d=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},h=t.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=d.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],d=[],f=[],h=0;256>h;h++)f[h]=128>h?h<<1:h<<1^283;var y=0,g=0;for(h=0;256>h;h++){var v=(v=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&v^99;r[y]=v,o[v]=y;var m=f[y],b=f[m],_=f[b],S=257*f[v]^16843008*v;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*m^16843008*y,c[v]=S<<24|S>>>8,l[v]=S<<16|S>>>16,p[v]=S<<8|S>>>24,d[v]=S,y?(y=m^f[f[f[_^m]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^d[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,d,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],d=e[t+3]^n[3],f=4,h=1;h>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&d]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[d>>>8&255]^a[255&c]^n[f++],v=r[p>>>24]^o[d>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];d=r[d>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=v}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&d])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[d>>>8&255]<<8|s[255&c])^n[f++],v=(s[p>>>24]<<24|s[d>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],d=(s[d>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=v,e[t+3]=d},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,d=r(u,["uuid","channel"]);d.user=l,d.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:d})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var h=void 0;try{h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){h=void 0;try{var g;h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=h?h:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,d=i.length>0;(l||p||d)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),d&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,h=s.length>0,y=u.length>0;return(f||h||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),h&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ve={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},me=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,d=e.file,f=e.message,h=e.cipherKey,y=e.meta,g=e.ttl,v=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,m,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!d)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(d),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,m=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(h||l)?null!=h?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(h,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&d.uri?(A=(T=p).POSTFILE,k=[m,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[m,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[m,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[m,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:v,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&v.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&v.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&v.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&v.include.push("uuid.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&d.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&d.include.push("uuid")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&v.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&v.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&v.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&v.include.push("channel.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,d=void 0!==p&&p,f=t.manage,h=void 0!==f&&f,y=t.get,g=void 0!==y&&y,v=t.join,m=void 0!==v&&v,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=d?"1":"0",P.m=h?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=m?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,d=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,d=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),d=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),h=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||h||d||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,d=t.includeUUID,f=void 0===d||d,h=t.includeMessageType,y=void 0===h||h,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],d=l[1],f=l[2];try{for(var h=a(this.currentState.exitEffects),y=h.next();!y.done;y=h.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var m=this.currentContext;this.currentContext=d,this.notify({type:"transitionDone",fromState:v,fromContext:m,toState:p,toContext:d,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&a(e),[2]}))}))}))),r.on(dt.type,ut((function(e,t,n){var a=n.emitStatus;return o(r,void 0,void 0,(function(){return i(this,(function(t){return a(e),[2]}))}))}))),r.on(ft.type,ut((function(e,n,a){var s=a.receiveMessages,u=a.delay,c=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r.on(ht.type,ut((function(e,n,a){var s=a.handshake,u=a.delay,c=a.presenceState,l=a.config;return o(r,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={abortSignal:n,channels:e.channels,channelGroups:e.groups,filterExpression:l.filterExpression},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(l.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r}return t(n,e),n}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){var n,r,o,i,a;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(o=null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.timetoken)&&void 0!==o?o:"0",region:null!==(a=null===(i=t.payload)||void 0===i?void 0:i.region)&&void 0!==a?a:0}})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){var r,o,i,a,s,u;return Ft.with(n(n({},e),{cursor:{timetoken:null!==(a=null!==(o=null===(r=t.payload)||void 0===r?void 0:r.timetoken)&&void 0!==o?o:null===(i=e.cursor)||void 0===i?void 0:i.timetoken)&&void 0!==a?a:"0",region:null!==(u=null===(s=t.payload)||void 0===s?void 0:s.region)&&void 0!==u?u:0}}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:"0",region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:0}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){var n,r;return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.cursor.timetoken,region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[dt({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){var n,r;return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){var n,r;return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ht(e)})),Dt.onExit((function(){return ht.cancel})),Dt.on(bt.type,(function(e,t){var n,r={timetoken:null!==(n=null==e?void 0:e.timetoken)&&void 0!==n?n:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:r},[dt({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,timetoken:e.timetoken,reason:t.payload},[dt({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){var t;return jt.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(t=e.timetoken)&&void 0!==t?t:"0",region:0}})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(vt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=e.cursor)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:t.payload.timetoken,region:t.payload.region}},[dt({category:R.PNConnectedCategory})])})),Ft.on(mt.type,(function(e,t){var n;return Dt.with({channels:e.channels,groups:e.groups,timetoken:null===(n=e.cursor)||void 0===n?void 0:n.timetoken,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,n,r){var s=r.heartbeat,u=r.presenceState,c=r.config;return o(a,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),n={channels:e.channels,channelGroups:e.groups},c.maintainPresenceState&&(n.state=u),[4,s(n)];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,n,r){var s=r.heartbeat,u=r.retryDelay,c=r.presenceState,l=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(t){return{delay:t.delay,maximumRetry:t.maximumRetry,shouldRetry:function(t,n){var r;return!e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)&&this.maximumRetry>n},getDelay:function(e){return 1e3*(this.delay+Math.random())},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.ExponentialRetryPolicy=function(t){return{minimumDelay:t.minimumDelay,maximumDelay:t.maximumDelay,maximumRetry:t.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){var t=1e3*(Math.pow(2,e)+Math.random());return t>this.maximumDelay?this.maximumDelay:t},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.excludedErrorCodes=[403,429],e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var d=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(d=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=d.message,a.file={id:d.file.id,name:d.file.name,url:this.getFileUrl({id:d.file.id,name:d.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var h;f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),dn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var d=new I({maximumSamplesCount:6e4});this._telemetryManager=d;var f=this._config.cryptoModule,h={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:d,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,h,Je),v=Q.bind(this,h,ae),b=Q.bind(this,h,ue),_=Q.bind(this,h,le),S=Q.bind(this,h,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,h,ue),this.iAmAway=Q.bind(this,h,ae),this.setPresenceState=Q.bind(this,h,le),this.handshake=Q.bind(this,h,Qe),this.receiveMessages=Q.bind(this,h,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:h,listenerManager:this._listenerManager,getFileUrl:function(e){return be(h,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*h.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:h.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:h.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:h.crypto,config:h.config,listenerManager:w,getFileUrl:function(e){return be(h,e)},cryptoModule:h.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,h,ee),listChannels:Q.bind(this,h,te),addChannels:Q.bind(this,h,X),removeChannels:Q.bind(this,h,Y),deleteGroup:Q.bind(this,h,Z)},this.push={addChannels:Q.bind(this,h,ne),removeChannels:Q.bind(this,h,re),deleteDevice:Q.bind(this,h,ie),listChannels:Q.bind(this,h,oe)},this.hereNow=Q.bind(this,h,pe),this.whereNow=Q.bind(this,h,se),this.getState=Q.bind(this,h,ce),this.grant=Q.bind(this,h,Ue),this.grantToken=Q.bind(this,h,Ge),this.audit=Q.bind(this,h,xe),this.revokeToken=Q.bind(this,h,Le),this.publish=Q.bind(this,h,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,h,He),this.history=Q.bind(this,h,qe),this.deleteMessages=Q.bind(this,h,ze),this.messageCounts=Q.bind(this,h,Ve),this.fetchMessages=Q.bind(this,h,We),this.addMessageAction=Q.bind(this,h,de),this.removeMessageAction=Q.bind(this,h,fe),this.getMessageActions=Q.bind(this,h,he),this.listFiles=Q.bind(this,h,ye);var T=Q.bind(this,h,ge);this.publishFile=Q.bind(this,h,ve),this.sendFile=me({generateUploadUrl:T,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return be(h,e)},this.downloadFile=Q.bind(this,h,_e),this.deleteFile=Q.bind(this,h,Se),this.objects={getAllUUIDMetadata:Q.bind(this,h,we),getUUIDMetadata:Q.bind(this,h,Oe),setUUIDMetadata:Q.bind(this,h,Pe),removeUUIDMetadata:Q.bind(this,h,Ee),getAllChannelMetadata:Q.bind(this,h,Te),getChannelMetadata:Q.bind(this,h,Ae),setChannelMetadata:Q.bind(this,h,ke),removeChannelMetadata:Q.bind(this,h,Ce),getChannelMembers:Q.bind(this,h,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function hn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?hn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},vn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var h=zn(a,p);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},dr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(dr);var fr=pr,hr=dr.exports,yr=hr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),vr="function"==typeof Map&&Map.prototype,mr=Object.getOwnPropertyDescriptor&&vr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=vr&&mr&&"function"==typeof mr.get?mr.get:null,_r=vr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?hr(n):n},vo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var d=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var h=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,f);return"[Function"+(h?": "+h:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var v="<"+Ur.call(String(t.nodeName)),m=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,f);return d&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,d)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,d)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,d)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":d?k+"{"+fo(P,d)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},mo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?m.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(m);O=c?E.sort(c):E}for(var T=o&&Ho(m)&&1===m.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+d:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const di=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&di.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const hi=ai;var yi=gi;function gi(){}function vi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function mi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function v(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&m(t,n,e[n]);return t.join("&")}function m(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){m(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&m(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=v,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,d.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=v(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||h,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:m(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:v(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return hn(d.decode(e))}),v),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(dn);return Bi})); diff --git a/lib/core/components/listener_manager.js b/lib/core/components/listener_manager.js index d68673878..9518fb550 100644 --- a/lib/core/components/listener_manager.js +++ b/lib/core/components/listener_manager.js @@ -8,8 +8,11 @@ var default_1 = /** @class */ (function () { function default_1() { this._listeners = []; } - default_1.prototype.addListener = function (newListeners) { - this._listeners.push(newListeners); + default_1.prototype.addListener = function (newListener) { + if (this._listeners.includes(newListener)) { + return; + } + this._listeners.push(newListener); }; default_1.prototype.removeListener = function (deprecatedListener) { var newListeners = []; diff --git a/lib/event-engine/states/handshake_reconnecting.js b/lib/event-engine/states/handshake_reconnecting.js index 16c7a83b1..3395d5070 100644 --- a/lib/event-engine/states/handshake_reconnecting.js +++ b/lib/event-engine/states/handshake_reconnecting.js @@ -58,8 +58,8 @@ exports.HandshakeReconnectingState.on(events_1.disconnect.type, function (contex groups: context.groups, cursor: { timetoken: (_a = context.timetoken) !== null && _a !== void 0 ? _a : '0', - region: 0 - } + region: 0, + }, }); }); exports.HandshakeReconnectingState.on(events_1.subscriptionChange.type, function (_, event) { diff --git a/lib/event-engine/states/handshake_stopped.js b/lib/event-engine/states/handshake_stopped.js index ef17507a3..177c7ad70 100644 --- a/lib/event-engine/states/handshake_stopped.js +++ b/lib/event-engine/states/handshake_stopped.js @@ -21,7 +21,7 @@ exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (con return exports.HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: context.cursor + cursor: context.cursor, }); }); exports.HandshakeStoppedState.on(events_1.reconnect.type, function (context, event) { diff --git a/lib/event-engine/states/receive_stopped.js b/lib/event-engine/states/receive_stopped.js index 370f96752..1b49d352a 100644 --- a/lib/event-engine/states/receive_stopped.js +++ b/lib/event-engine/states/receive_stopped.js @@ -20,7 +20,7 @@ exports.ReceiveStoppedState.on(events_1.restore.type, function (context, event) groups: event.payload.groups, cursor: { timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region + region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, }, }); }); From 1bdda1ff8b903ed623ff5c6f385f4f503c7af41e Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Sun, 14 Jan 2024 20:37:26 +0530 Subject: [PATCH 48/63] retry delay can be override by retry after value --- src/event-engine/core/retryPolicy.ts | 21 +++++++++++++-------- src/event-engine/dispatcher.ts | 18 ++++++++---------- src/event-engine/presence/dispatcher.ts | 16 +++++++--------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/event-engine/core/retryPolicy.ts b/src/event-engine/core/retryPolicy.ts index 4d0203da9..d3ae9e6b3 100644 --- a/src/event-engine/core/retryPolicy.ts +++ b/src/event-engine/core/retryPolicy.ts @@ -1,24 +1,26 @@ export class RetryPolicy { - static excludedErrorCodes = [403, 429]; static LinearRetryPolicy(configuration: LinearRetryPolicyConfiguration) { return { delay: configuration.delay, maximumRetry: configuration.maximumRetry, shouldRetry(error: any, attempt: number) { - if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) { + if (error?.status?.statusCode === 403) { return false; } return this.maximumRetry > attempt; }, - getDelay(_: number) { + getDelay(_: number, reason: any) { + if (reason?.retryAfter) { + return reason.retryAfter * 1000; + } return (this.delay + Math.random()) * 1000; }, getGiveupReason(error: any, attempt: number) { if (this.maximumRetry <= attempt) { return 'retry attempts exhaused.'; } - if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) { - return 'forbidden or too many requests.'; + if (error?.status?.statusCode === 403) { + return 'forbidden operation.'; } return 'unknown error'; }, @@ -38,7 +40,10 @@ export class RetryPolicy { return this.maximumRetry > attempt; }, - getDelay(attempt: number) { + getDelay(attempt: number, reason: any) { + if (reason?.retryAfter) { + return reason.retryAfter * 1000; + } const calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; if (calculatedDelay > this.maximumDelay) { return this.maximumDelay; @@ -51,8 +56,8 @@ export class RetryPolicy { if (this.maximumRetry <= attempt) { return 'retry attempts exhaused.'; } - if (RetryPolicy.excludedErrorCodes.includes(error?.status?.statusCode)) { - return 'forbidden or too many requests.'; + if (error?.status?.statusCode === 403) { + return 'forbidden operation.'; } return 'unknown error'; }, diff --git a/src/event-engine/dispatcher.ts b/src/event-engine/dispatcher.ts index ca2945cbc..3054d5ee2 100644 --- a/src/event-engine/dispatcher.ts +++ b/src/event-engine/dispatcher.ts @@ -28,14 +28,13 @@ export class EventEngineDispatcher extends Dispatcher { try { - const heartbeatParams: any = { + const result = await heartbeat({ channels: payload.channels, channelGroups: payload.groups, - }; - if (config.maintainPresenceState) heartbeatParams.state = presenceState; - const result = await heartbeat(heartbeatParams); + ...(config.maintainPresenceState && { state: presenceState }), + }); engine.transition(events.heartbeatSuccess(200)); } catch (e) { if (e instanceof PubNubError) { @@ -71,15 +70,14 @@ export class PresenceEventEngineDispatcher extends Dispatcher { if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) { abortSignal.throwIfAborted(); - await retryDelay(config.retryConfiguration.getDelay(payload.attempts)); + await retryDelay(config.retryConfiguration.getDelay(payload.attempts, payload.reason)); abortSignal.throwIfAborted(); try { - const heartbeatParams: any = { + const result = await heartbeat({ channels: payload.channels, channelGroups: payload.groups, - }; - if (config.maintainPresenceState) heartbeatParams.state = presenceState; - const result = await heartbeat(heartbeatParams); + ...(config.maintainPresenceState && { state: presenceState }), + }); return engine.transition(events.heartbeatSuccess(200)); } catch (e) { if (e instanceof Error && e.message === 'Aborted') { From 1f050fb22df5195f3b75b13a738f88624a4472a6 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Sun, 14 Jan 2024 20:38:07 +0530 Subject: [PATCH 49/63] handled cursor across the states --- src/event-engine/states/handshake_failed.ts | 14 ++++++-------- .../states/handshake_reconnecting.ts | 18 ++++++++---------- src/event-engine/states/handshake_stopped.ts | 11 ++++------- src/event-engine/states/handshaking.ts | 12 ++++++------ src/event-engine/states/receive_failed.ts | 11 +++++++---- .../states/receive_reconnecting.ts | 4 ++-- src/event-engine/states/receive_stopped.ts | 8 ++++---- src/event-engine/states/receiving.ts | 4 ++-- src/event-engine/states/unsubscribed.ts | 5 +---- 9 files changed, 40 insertions(+), 47 deletions(-) diff --git a/src/event-engine/states/handshake_failed.ts b/src/event-engine/states/handshake_failed.ts index 2fbaf177c..f270edf00 100644 --- a/src/event-engine/states/handshake_failed.ts +++ b/src/event-engine/states/handshake_failed.ts @@ -4,11 +4,12 @@ import { Events, reconnect, restore, subscriptionChange, unsubscribeAll } from ' import { PubNubError } from '../../core/components/endpoint'; import { HandshakingState } from './handshaking'; import { UnsubscribedState } from './unsubscribed'; +import { Cursor } from '../../models/Cursor'; export type HandshakeFailedStateContext = { channels: string[]; groups: string[]; - timetoken?: string; + cursor?: Cursor; reason: PubNubError; }; @@ -23,20 +24,17 @@ HandshakeFailedState.on(reconnect.type, (context, event) => HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: { - timetoken: event.payload?.timetoken ?? context.timetoken ?? '0', - region: event.payload?.region ?? 0, - }, + cursor: context.cursor, }), ); -HandshakeFailedState.on(restore.type, (_, event) => +HandshakeFailedState.on(restore.type, (context, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context?.cursor?.region ?? 0, }, }), ); diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index 063146fb5..75a3c6cf1 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -17,11 +17,12 @@ import { HandshakingState } from './handshaking'; import { ReceivingState } from './receiving'; import { UnsubscribedState } from './unsubscribed'; import categoryConstants from '../../core/constants/categories'; +import { Cursor } from '../../models/Cursor'; export type HandshakeReconnectingStateContext = { channels: string[]; groups: string[]; - timetoken?: string; + cursor?: Cursor; attempts: number; reason: PubNubError; @@ -36,7 +37,7 @@ HandshakeReconnectingState.onExit(() => handshakeReconnect.cancel); HandshakeReconnectingState.on(handshakeReconnectSuccess.type, (context, event) => { const cursor = { - timetoken: context?.timetoken ?? event.payload.cursor.timetoken, + timetoken: !!context.cursor?.timetoken ? context.cursor?.timetoken : event.payload.cursor.timetoken, region: event.payload.cursor.region, }; return ReceivingState.with( @@ -58,7 +59,7 @@ HandshakeReconnectingState.on(handshakeReconnectGiveup.type, (context, event) => { groups: context.groups, channels: context.channels, - timetoken: context.timetoken, + cursor: context.cursor, reason: event.payload, }, [emitStatus({ category: categoryConstants.PNConnectionErrorCategory, error: event.payload?.message })], @@ -69,10 +70,7 @@ HandshakeReconnectingState.on(disconnect.type, (context) => HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - cursor: { - timetoken: context.timetoken ?? '0', - region: 0, - }, + cursor: context.cursor, }), ); @@ -80,13 +78,13 @@ HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), ); -HandshakeReconnectingState.on(restore.type, (_, event) => +HandshakeReconnectingState.on(restore.type, (context, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context?.cursor?.region ?? 0, }, }), ); diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index 2e132aa97..115393631 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -24,20 +24,17 @@ HandshakeStoppedState.on(subscriptionChange.type, (context, event) => HandshakeStoppedState.on(reconnect.type, (context, event) => HandshakingState.with({ ...context, - cursor: { - timetoken: event.payload?.timetoken ?? context.cursor?.timetoken ?? '0', - region: event.payload?.region ?? 0, - }, + cursor: event.payload.cursor, }), ); -HandshakeStoppedState.on(restore.type, (_, event) => +HandshakeStoppedState.on(restore.type, (context, event) => HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context?.cursor?.region ?? 0, }, }), ); diff --git a/src/event-engine/states/handshaking.ts b/src/event-engine/states/handshaking.ts index accfe6d88..a5a894b9b 100644 --- a/src/event-engine/states/handshaking.ts +++ b/src/event-engine/states/handshaking.ts @@ -8,7 +8,6 @@ import { handshakeSuccess, subscriptionChange, unsubscribeAll, - reconnect, } from '../events'; import { HandshakeReconnectingState } from './handshake_reconnecting'; import { HandshakeStoppedState } from './handshake_stopped'; @@ -42,7 +41,7 @@ HandshakingState.on(handshakeSuccess.type, (context, event) => channels: context.channels, groups: context.groups, cursor: { - timetoken: context.cursor?.timetoken ?? event.payload.timetoken, + timetoken: !!context?.cursor?.timetoken ? context?.cursor?.timetoken : event.payload.timetoken, region: event.payload.region, }, }, @@ -58,7 +57,7 @@ HandshakingState.on(handshakeFailure.type, (context, event) => { return HandshakeReconnectingState.with({ channels: context.channels, groups: context.groups, - timetoken: context.cursor?.timetoken, + cursor: context.cursor, attempts: 0, reason: event.payload, }); @@ -68,16 +67,17 @@ HandshakingState.on(disconnect.type, (context) => HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, + cursor: context.cursor, }), ); -HandshakingState.on(restore.type, (_, event) => +HandshakingState.on(restore.type, (context, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context?.cursor?.region ?? 0, }, }), ); diff --git a/src/event-engine/states/receive_failed.ts b/src/event-engine/states/receive_failed.ts index a1bdd4414..76fb1180e 100644 --- a/src/event-engine/states/receive_failed.ts +++ b/src/event-engine/states/receive_failed.ts @@ -21,8 +21,8 @@ ReceiveFailedState.on(reconnect.type, (context, event) => channels: context.channels, groups: context.groups, cursor: { - timetoken: event.payload?.timetoken ?? '0', - region: event.payload?.region ?? 0, + timetoken: !!event.payload.cursor.timetoken ? event.payload.cursor?.timetoken : context.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }), ); @@ -34,11 +34,14 @@ ReceiveFailedState.on(subscriptionChange.type, (_, event) => }), ); -ReceiveFailedState.on(restore.type, (_, event) => +ReceiveFailedState.on(restore.type, (context, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: { timetoken: event.payload.timetoken, region: event.payload?.region ?? 0 }, + cursor: { + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + }, }), ); diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index 573ddf33a..3e4251125 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -77,8 +77,8 @@ ReceiveReconnectingState.on(restore.type, (context, event) => channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }), ); diff --git a/src/event-engine/states/receive_stopped.ts b/src/event-engine/states/receive_stopped.ts index ce75c3b7f..86a60d411 100644 --- a/src/event-engine/states/receive_stopped.ts +++ b/src/event-engine/states/receive_stopped.ts @@ -26,8 +26,8 @@ ReceiveStoppedState.on(restore.type, (context, event) => channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }), ); @@ -37,8 +37,8 @@ ReceiveStoppedState.on(reconnect.type, (context, event) => channels: context.channels, groups: context.groups, cursor: { - timetoken: event.payload?.timetoken ?? context.cursor.timetoken, - region: event.payload?.region ?? context.cursor.region, + timetoken: !!event.payload.cursor.timetoken ? event.payload.cursor?.timetoken : context.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }), ); diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index a16d24452..8e2408991 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -53,8 +53,8 @@ ReceivingState.on(restore.type, (context, event) => { channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); diff --git a/src/event-engine/states/unsubscribed.ts b/src/event-engine/states/unsubscribed.ts index 349037cb1..70794694e 100644 --- a/src/event-engine/states/unsubscribed.ts +++ b/src/event-engine/states/unsubscribed.ts @@ -16,9 +16,6 @@ UnsubscribedState.on(restore.type, (_, event) => { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: { - timetoken: event.payload.timetoken, - region: event.payload?.region ?? 0, - }, + cursor: event.payload.cursor, }); }); From d2b28095d9c125ca0871d770149f8ead6e72b29a Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Sun, 14 Jan 2024 20:38:33 +0530 Subject: [PATCH 50/63] manage cursor from event struct --- src/event-engine/events.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/event-engine/events.ts b/src/event-engine/events.ts index 70e7a1448..c0341d8f0 100644 --- a/src/event-engine/events.ts +++ b/src/event-engine/events.ts @@ -12,8 +12,10 @@ export const restore = createEvent( (channels: string[], groups: string[], timetoken: string, region?: number) => ({ channels, groups, - timetoken, - region, + cursor: { + timetoken: timetoken, + region: region ?? 0, + }, }), ); @@ -41,8 +43,10 @@ export const receiveReconnectGiveup = createEvent('RECEIVING_RECONNECT_GIVEUP', export const disconnect = createEvent('DISCONNECT', () => ({})); export const reconnect = createEvent('RECONNECT', (timetoken?: string, region?: number) => ({ - timetoken, - region, + cursor: { + timetoken: timetoken ?? '', + region: region ?? 0, + }, })); export const unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', () => ({})); From aa306aaf570c762793de518fe482913a1c301d91 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Sun, 14 Jan 2024 20:38:55 +0530 Subject: [PATCH 51/63] dist and lib --- dist/web/pubnub.js | 178 +++++++----------- dist/web/pubnub.min.js | 4 +- lib/event-engine/core/retryPolicy.js | 21 ++- lib/event-engine/dispatcher.js | 39 ++-- lib/event-engine/events.js | 12 +- lib/event-engine/presence/dispatcher.js | 22 +-- lib/event-engine/states/handshake_failed.js | 12 +- .../states/handshake_reconnecting.js | 18 +- lib/event-engine/states/handshake_stopped.js | 12 +- lib/event-engine/states/handshaking.js | 12 +- lib/event-engine/states/receive_failed.js | 14 +- .../states/receive_reconnecting.js | 5 +- lib/event-engine/states/receive_stopped.js | 11 +- lib/event-engine/states/receiving.js | 5 +- lib/event-engine/states/unsubscribed.js | 6 +- 15 files changed, 155 insertions(+), 216 deletions(-) diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index b718062eb..fcfc6e7e2 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -7161,8 +7161,10 @@ var restore = createEvent('SUBSCRIPTION_RESTORED', function (channels, groups, timetoken, region) { return ({ channels: channels, groups: groups, - timetoken: timetoken, - region: region, + cursor: { + timetoken: timetoken, + region: region !== null && region !== void 0 ? region : 0, + }, }); }); var handshakeSuccess = createEvent('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); var handshakeFailure = createEvent('HANDSHAKE_FAILURE', function (error) { return error; }); @@ -7184,8 +7186,10 @@ var receiveReconnectGiveup = createEvent('RECEIVING_RECONNECT_GIVEUP', function (error) { return error; }); var disconnect$1 = createEvent('DISCONNECT', function () { return ({}); }); var reconnect$1 = createEvent('RECONNECT', function (timetoken, region) { return ({ - timetoken: timetoken, - region: region, + cursor: { + timetoken: timetoken !== null && timetoken !== void 0 ? timetoken : '', + region: region !== null && region !== void 0 ? region : 0, + }, }); }); var unsubscribeAll = createEvent('UNSUBSCRIBE_ALL', function () { return ({}); }); @@ -7196,7 +7200,7 @@ _this.on(handshake.type, asyncHandler(function (payload, abortSignal, _a) { var handshake = _a.handshake, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var handshakeParams, result, e_1; + var result, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -7204,15 +7208,7 @@ _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); - handshakeParams = { - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - }; - if (config.maintainPresenceState) - handshakeParams.state = presenceState; - return [4 /*yield*/, handshake(handshakeParams)]; + return [4 /*yield*/, handshake(__assign({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, filterExpression: config.filterExpression }, (config.maintainPresenceState && { state: presenceState })))]; case 2: result = _b.sent(); return [2 /*return*/, engine.transition(handshakeSuccess(result))]; @@ -7296,7 +7292,7 @@ case 0: if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts, payload.reason))]; case 1: _b.sent(); abortSignal.throwIfAborted(); @@ -7333,28 +7329,20 @@ _this.on(handshakeReconnect.type, asyncHandler(function (payload, abortSignal, _a) { var handshake = _a.handshake, delay = _a.delay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var handshakeParams, result, error_3; + var result, error_3; return __generator(this, function (_b) { switch (_b.label) { case 0: if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts, payload.reason))]; case 1: _b.sent(); abortSignal.throwIfAborted(); _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - handshakeParams = { - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - }; - if (config.maintainPresenceState) - handshakeParams.state = presenceState; - return [4 /*yield*/, handshake(handshakeParams)]; + return [4 /*yield*/, handshake(__assign({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, filterExpression: config.filterExpression }, (config.maintainPresenceState && { state: presenceState })))]; case 3: result = _b.sent(); return [2 /*return*/, engine.transition(handshakeReconnectSuccess(result))]; @@ -7384,24 +7372,20 @@ return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); HandshakeFailedState.on(reconnect$1.type, function (context, event) { - var _a, _b, _c, _d, _e; return HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: { - timetoken: (_c = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.timetoken) !== null && _c !== void 0 ? _c : '0', - region: (_e = (_d = event.payload) === null || _d === void 0 ? void 0 : _d.region) !== null && _e !== void 0 ? _e : 0, - }, + cursor: context.cursor, }); }); - HandshakeFailedState.on(restore.type, function (_, event) { + HandshakeFailedState.on(restore.type, function (context, event) { var _a, _b; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); @@ -7416,20 +7400,16 @@ }); }); HandshakeStoppedState.on(reconnect$1.type, function (context, event) { - var _a, _b, _c, _d, _e, _f; - return HandshakingState.with(__assign(__assign({}, context), { cursor: { - timetoken: (_d = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : (_c = context.cursor) === null || _c === void 0 ? void 0 : _c.timetoken) !== null && _d !== void 0 ? _d : '0', - region: (_f = (_e = event.payload) === null || _e === void 0 ? void 0 : _e.region) !== null && _f !== void 0 ? _f : 0, - } })); + return HandshakingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor })); }); - HandshakeStoppedState.on(restore.type, function (_, event) { + HandshakeStoppedState.on(restore.type, function (context, event) { var _a, _b; return HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); @@ -7437,13 +7417,13 @@ var ReceiveFailedState = new State('RECEIVE_FAILED'); ReceiveFailedState.on(reconnect$1.type, function (context, event) { - var _a, _b, _c, _d; + var _a; return HandshakingState.with({ channels: context.channels, groups: context.groups, cursor: { - timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : '0', - region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : 0, + timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); @@ -7453,12 +7433,14 @@ groups: event.payload.groups, }); }); - ReceiveFailedState.on(restore.type, function (_, event) { - var _a, _b; + ReceiveFailedState.on(restore.type, function (context, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: { timetoken: event.payload.timetoken, region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0 }, + cursor: { + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + }, }); }); ReceiveFailedState.on(unsubscribeAll.type, function (_) { return UnsubscribedState.with(undefined); }); @@ -7472,24 +7454,23 @@ }); }); ReceiveStoppedState.on(restore.type, function (context, event) { - var _a, _b; return ReceiveStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); ReceiveStoppedState.on(reconnect$1.type, function (context, event) { - var _a, _b, _c, _d; + var _a; return HandshakingState.with({ channels: context.channels, groups: context.groups, cursor: { - timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.cursor.timetoken, - region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : context.cursor.region, + timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); @@ -7525,13 +7506,12 @@ }, [emitStatus$1({ category: categories.PNDisconnectedCategory })]); }); ReceiveReconnectingState.on(restore.type, function (context, event) { - var _a, _b; return ReceivingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); @@ -7565,7 +7545,6 @@ }); }); ReceivingState.on(restore.type, function (context, event) { - var _a, _b; if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { return UnsubscribedState.with(undefined); } @@ -7573,8 +7552,8 @@ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); @@ -7596,9 +7575,9 @@ HandshakeReconnectingState.onEnter(function (context) { return handshakeReconnect(context); }); HandshakeReconnectingState.onExit(function () { return handshakeReconnect.cancel; }); HandshakeReconnectingState.on(handshakeReconnectSuccess.type, function (context, event) { - var _a; + var _a, _b; var cursor = { - timetoken: (_a = context === null || context === void 0 ? void 0 : context.timetoken) !== null && _a !== void 0 ? _a : event.payload.cursor.timetoken, + timetoken: !!((_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) ? (_b = context.cursor) === null || _b === void 0 ? void 0 : _b.timetoken : event.payload.cursor.timetoken, region: event.payload.cursor.region, }; return ReceivingState.with({ @@ -7615,32 +7594,28 @@ return HandshakeFailedState.with({ groups: context.groups, channels: context.channels, - timetoken: context.timetoken, + cursor: context.cursor, reason: event.payload, }, [emitStatus$1({ category: categories.PNConnectionErrorCategory, error: (_a = event.payload) === null || _a === void 0 ? void 0 : _a.message })]); }); HandshakeReconnectingState.on(disconnect$1.type, function (context) { - var _a; return HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - cursor: { - timetoken: (_a = context.timetoken) !== null && _a !== void 0 ? _a : '0', - region: 0, - }, + cursor: context.cursor, }); }); HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); - HandshakeReconnectingState.on(restore.type, function (_, event) { + HandshakeReconnectingState.on(restore.type, function (context, event) { var _a, _b; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); @@ -7661,7 +7636,7 @@ channels: context.channels, groups: context.groups, cursor: { - timetoken: (_b = (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : event.payload.timetoken, + timetoken: !!((_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) ? (_b = context === null || context === void 0 ? void 0 : context.cursor) === null || _b === void 0 ? void 0 : _b.timetoken : event.payload.timetoken, region: event.payload.region, }, }, [ @@ -7671,11 +7646,10 @@ ]); }); HandshakingState.on(handshakeFailure.type, function (context, event) { - var _a; return HandshakeReconnectingState.with({ channels: context.channels, groups: context.groups, - timetoken: (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken, + cursor: context.cursor, attempts: 0, reason: event.payload, }); @@ -7684,16 +7658,17 @@ return HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, + cursor: context.cursor, }); }); - HandshakingState.on(restore.type, function (_, event) { + HandshakingState.on(restore.type, function (context, event) { var _a, _b; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); @@ -7707,14 +7682,10 @@ }); }); UnsubscribedState.on(restore.type, function (_, event) { - var _a, _b; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, - }, + cursor: event.payload.cursor, }); }); @@ -7847,18 +7818,12 @@ _this.on(heartbeat.type, asyncHandler(function (payload, _, _a) { var heartbeat = _a.heartbeat, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var heartbeatParams, e_1; + var e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); - heartbeatParams = { - channels: payload.channels, - channelGroups: payload.groups, - }; - if (config.maintainPresenceState) - heartbeatParams.state = presenceState; - return [4 /*yield*/, heartbeat(heartbeatParams)]; + return [4 /*yield*/, heartbeat(__assign({ channels: payload.channels, channelGroups: payload.groups }, (config.maintainPresenceState && { state: presenceState })))]; case 1: _b.sent(); engine.transition(heartbeatSuccess(200)); @@ -7918,26 +7883,20 @@ _this.on(delayedHeartbeat.type, asyncHandler(function (payload, abortSignal, _a) { var heartbeat = _a.heartbeat, retryDelay = _a.retryDelay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var heartbeatParams, e_3; + var e_3; return __generator(this, function (_b) { switch (_b.label) { case 0: if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, retryDelay(config.retryConfiguration.getDelay(payload.attempts))]; + return [4 /*yield*/, retryDelay(config.retryConfiguration.getDelay(payload.attempts, payload.reason))]; case 1: _b.sent(); abortSignal.throwIfAborted(); _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - heartbeatParams = { - channels: payload.channels, - channelGroups: payload.groups, - }; - if (config.maintainPresenceState) - heartbeatParams.state = presenceState; - return [4 /*yield*/, heartbeat(heartbeatParams)]; + return [4 /*yield*/, heartbeat(__assign({ channels: payload.channels, channelGroups: payload.groups }, (config.maintainPresenceState && { state: presenceState })))]; case 3: _b.sent(); return [2 /*return*/, engine.transition(heartbeatSuccess(200))]; @@ -8195,12 +8154,15 @@ maximumRetry: configuration.maximumRetry, shouldRetry: function (error, attempt) { var _a; - if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { return false; } return this.maximumRetry > attempt; }, - getDelay: function (_) { + getDelay: function (_, reason) { + if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { + return reason.retryAfter * 1000; + } return (this.delay + Math.random()) * 1000; }, getGiveupReason: function (error, attempt) { @@ -8208,8 +8170,8 @@ if (this.maximumRetry <= attempt) { return 'retry attempts exhaused.'; } - if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { - return 'forbidden or too many requests.'; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return 'forbidden operation.'; } return 'unknown error'; }, @@ -8227,7 +8189,10 @@ } return this.maximumRetry > attempt; }, - getDelay: function (attempt) { + getDelay: function (attempt, reason) { + if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { + return reason.retryAfter * 1000; + } var calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; if (calculatedDelay > this.maximumDelay) { return this.maximumDelay; @@ -8241,14 +8206,13 @@ if (this.maximumRetry <= attempt) { return 'retry attempts exhaused.'; } - if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { - return 'forbidden or too many requests.'; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return 'forbidden operation.'; } return 'unknown error'; }, }; }; - RetryPolicy.excludedErrorCodes = [403, 429]; return RetryPolicy; }()); diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 83fc694da..65a94ad05 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return d(3,o.length),p(o);default:var f;if(Array.isArray(t))for(d(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var v=function e(){var o,d,v=l(),m=v>>5,b=31&v;if(7===m)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((d=h(b))<0&&(m<2||6=0;)S+=d,_.push(c(d));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(d);case 3:var P=[];if(d<0)for(;(d=y(m))>=0;)g(P,d);else g(P,d);return String.fromCharCode.apply(null,P);case 4:var E;if(d<0)for(E=[];!f();)E.push(e());else for(E=new Array(d),o=0;o0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return f(3,o.length),p(o);default:var h;if(Array.isArray(t))for(f(4,h=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,f,m=l(),v=m>>5,b=31&m;if(7===v)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((f=d(b))<0&&(v<2||6=0;)S+=f,_.push(c(f));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(f);case 3:var P=[];if(f<0)for(;(f=y(v))>=0;)g(P,f);else g(P,f);return String.fromCharCode.apply(null,P);case 4:var E;if(f<0)for(E=[];!h();)E.push(e());else for(E=new Array(f),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function v(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,h=(3&l)<<6|p>>0;o[s]=d,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=h)}return r}function m(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),d=2;d<=p;d++)if(!(l%d)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],d=0;64>d;d++){if(16>d)f[d]=0|e[t+d];else{var h=f[d-15],y=f[d-2];f[d]=((h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3)+f[d-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[d-16]}h=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[d]+f[d],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+h|0,s=i,i=o,o=r,r=h+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],d=e[i+4],f=e[i+5],h=e[i+6],y=e[i+7],g=e[i+8],v=e[i+9],m=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,d,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,h,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,v,12,c[9]),T=t(T,E,P,A,m,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,h,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,m,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,d,20,c[23]),P=n(P,A,T,E,v,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,d,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,m,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,h,23,c[43]),P=r(P,A,T,E,v,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,m,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,h,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,d,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,v,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),d=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},h=t.PasswordBasedCipher=d.extend({cfg:d.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=d.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,d.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],d=[],f=[],h=0;256>h;h++)f[h]=128>h?h<<1:h<<1^283;var y=0,g=0;for(h=0;256>h;h++){var v=(v=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&v^99;r[y]=v,o[v]=y;var m=f[y],b=f[m],_=f[b],S=257*f[v]^16843008*v;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*m^16843008*y,c[v]=S<<24|S>>>8,l[v]=S<<16|S>>>16,p[v]=S<<8|S>>>24,d[v]=S,y?(y=m^f[f[f[_^m]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^d[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,d,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],d=e[t+3]^n[3],f=4,h=1;h>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&d]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[d>>>8&255]^a[255&c]^n[f++],v=r[p>>>24]^o[d>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];d=r[d>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=v}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&d])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[d>>>8&255]<<8|s[255&c])^n[f++],v=(s[p>>>24]<<24|s[d>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],d=(s[d>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=v,e[t+3]=d},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,d=r(u,["uuid","channel"]);d.user=l,d.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:d})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var h=void 0;try{h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){h=void 0;try{var g;h=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){h=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=h?h:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,d=i.length>0;(l||p||d)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),d&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,h=s.length>0,y=u.length>0;return(f||h||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),h&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ve={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},me=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,d=e.file,f=e.message,h=e.cipherKey,y=e.meta,g=e.ttl,v=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,m,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!d)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(d),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,m=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(h||l)?null!=h?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(h,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&d.uri?(A=(T=p).POSTFILE,k=[m,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[m,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[m,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[m,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:v,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),d.include=d.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(d.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(d.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(d.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),d.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&v.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&v.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&v.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&v.include.push("uuid.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&d.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&d.include.push("uuid")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d,f,h,y,g,v={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&v.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&v.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&v.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&v.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&v.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&v.include.push("channel.type")),v.include=v.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(v.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(v.start=null===(d=t.page)||void 0===d?void 0:d.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(v.end=null===(h=t.page)||void 0===h?void 0:h.prev),(null==t?void 0:t.filter)&&(v.filter=t.filter),v.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(v.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),v},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,d={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&d.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&d.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&d.include.push("channel")),d.include=d.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(d.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(d.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(d.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(d.filter=t.filter),null!=t.limit&&(d.limit=t.limit),(null==t?void 0:t.sort)&&(d.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),d},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,d=void 0!==p&&p,f=t.manage,h=void 0!==f&&f,y=t.get,g=void 0!==y&&y,v=t.join,m=void 0!==v&&v,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=d?"1":"0",P.m=h?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=m?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,d=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,d=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),d&&Object.keys(d).forEach((function(e){s.permissions.patterns.channels[e]=De(d[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),d=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),h=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||h||d||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:m(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,d=t.includeUUID,f=void 0===d||d,h=t.includeMessageType,y=void 0===h||h,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],d=l[1],f=l[2];try{for(var h=a(this.currentState.exitEffects),y=h.next();!y.done;y=h.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}var v=this.currentState;this.currentState=p;var m=this.currentContext;this.currentContext=d,this.notify({type:"transitionDone",fromState:v,fromContext:m,toState:p,toContext:d,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&a(e),[2]}))}))}))),r.on(dt.type,ut((function(e,t,n){var a=n.emitStatus;return o(r,void 0,void 0,(function(){return i(this,(function(t){return a(e),[2]}))}))}))),r.on(ft.type,ut((function(e,n,a){var s=a.receiveMessages,u=a.delay,c=a.config;return o(r,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r.on(ht.type,ut((function(e,n,a){var s=a.handshake,u=a.delay,c=a.presenceState,l=a.config;return o(r,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={abortSignal:n,channels:e.channels,channelGroups:e.groups,filterExpression:l.filterExpression},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(l.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),r}return t(n,e),n}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){var n,r,o,i,a;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(o=null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.timetoken)&&void 0!==o?o:"0",region:null!==(a=null===(i=t.payload)||void 0===i?void 0:i.region)&&void 0!==a?a:0}})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){var r,o,i,a,s,u;return Ft.with(n(n({},e),{cursor:{timetoken:null!==(a=null!==(o=null===(r=t.payload)||void 0===r?void 0:r.timetoken)&&void 0!==o?o:null===(i=e.cursor)||void 0===i?void 0:i.timetoken)&&void 0!==a?a:"0",region:null!==(u=null===(s=t.payload)||void 0===s?void 0:s.region)&&void 0!==u?u:0}}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:"0",region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:0}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){var n,r;return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n,r,o,i;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:e.cursor.timetoken,region:null!==(i=null===(o=t.payload)||void 0===o?void 0:o.region)&&void 0!==i?i:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[dt({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){var n,r;return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){var n,r;return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[dt({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[dt({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return ht(e)})),Dt.onExit((function(){return ht.cancel})),Dt.on(bt.type,(function(e,t){var n,r={timetoken:null!==(n=null==e?void 0:e.timetoken)&&void 0!==n?n:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:r},[dt({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,timetoken:e.timetoken,reason:t.payload},[dt({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){var t;return jt.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(t=e.timetoken)&&void 0!==t?t:"0",region:0}})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(vt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!==(r=null===(n=e.cursor)||void 0===n?void 0:n.timetoken)&&void 0!==r?r:t.payload.timetoken,region:t.payload.region}},[dt({category:R.PNConnectedCategory})])})),Ft.on(mt.type,(function(e,t){var n;return Dt.with({channels:e.channels,groups:e.groups,timetoken:null===(n=e.cursor)||void 0===n?void 0:n.timetoken,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.timetoken,region:null!==(r=null===(n=t.payload)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,n,r){var s=r.heartbeat,u=r.presenceState,c=r.config;return o(a,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),n={channels:e.channels,channelGroups:e.groups},c.maintainPresenceState&&(n.state=u),[4,s(n)];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,n,r){var s=r.heartbeat,u=r.retryDelay,c=r.presenceState,l=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return l.retryConfiguration&&l.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(l.retryConfiguration.getDelay(e.attempts))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),r={channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&(r.state=c),[4,s(r)];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(t){return{delay:t.delay,maximumRetry:t.maximumRetry,shouldRetry:function(t,n){var r;return!e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)&&this.maximumRetry>n},getDelay:function(e){return 1e3*(this.delay+Math.random())},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.ExponentialRetryPolicy=function(t){return{minimumDelay:t.minimumDelay,maximumDelay:t.maximumDelay,maximumRetry:t.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e){var t=1e3*(Math.pow(2,e)+Math.random());return t>this.maximumDelay?this.maximumDelay:t},getGiveupReason:function(t,n){var r;return this.maximumRetry<=n?"retry attempts exhaused.":e.excludedErrorCodes.includes(null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.statusCode)?"forbidden or too many requests.":"unknown error"}}},e.excludedErrorCodes=[403,429],e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var d=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(d=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=d.message,a.file={id:d.file.id,name:d.file.name,url:this.getFileUrl({id:d.file.id,name:d.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var h;f=(h=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(h)):h}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),dn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var d=new I({maximumSamplesCount:6e4});this._telemetryManager=d;var f=this._config.cryptoModule,h={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:d,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&h.cryptoModule?(t=e,h.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,h,Je),v=Q.bind(this,h,ae),b=Q.bind(this,h,ue),_=Q.bind(this,h,le),S=Q.bind(this,h,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,h,ue),this.iAmAway=Q.bind(this,h,ae),this.setPresenceState=Q.bind(this,h,le),this.handshake=Q.bind(this,h,Qe),this.receiveMessages=Q.bind(this,h,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:h,listenerManager:this._listenerManager,getFileUrl:function(e){return be(h,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*h.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:h.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:h.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:v,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:h.crypto,config:h.config,listenerManager:w,getFileUrl:function(e){return be(h,e)},cryptoModule:h.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,h,ee),listChannels:Q.bind(this,h,te),addChannels:Q.bind(this,h,X),removeChannels:Q.bind(this,h,Y),deleteGroup:Q.bind(this,h,Z)},this.push={addChannels:Q.bind(this,h,ne),removeChannels:Q.bind(this,h,re),deleteDevice:Q.bind(this,h,ie),listChannels:Q.bind(this,h,oe)},this.hereNow=Q.bind(this,h,pe),this.whereNow=Q.bind(this,h,se),this.getState=Q.bind(this,h,ce),this.grant=Q.bind(this,h,Ue),this.grantToken=Q.bind(this,h,Ge),this.audit=Q.bind(this,h,xe),this.revokeToken=Q.bind(this,h,Le),this.publish=Q.bind(this,h,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,h,He),this.history=Q.bind(this,h,qe),this.deleteMessages=Q.bind(this,h,ze),this.messageCounts=Q.bind(this,h,Ve),this.fetchMessages=Q.bind(this,h,We),this.addMessageAction=Q.bind(this,h,de),this.removeMessageAction=Q.bind(this,h,fe),this.getMessageActions=Q.bind(this,h,he),this.listFiles=Q.bind(this,h,ye);var T=Q.bind(this,h,ge);this.publishFile=Q.bind(this,h,ve),this.sendFile=me({generateUploadUrl:T,publishFile:this.publishFile,modules:h}),this.getFileUrl=function(e){return be(h,e)},this.downloadFile=Q.bind(this,h,_e),this.deleteFile=Q.bind(this,h,Se),this.objects={getAllUUIDMetadata:Q.bind(this,h,we),getUUIDMetadata:Q.bind(this,h,Oe),setUUIDMetadata:Q.bind(this,h,Pe),removeUUIDMetadata:Q.bind(this,h,Ee),getAllChannelMetadata:Q.bind(this,h,Te),getChannelMetadata:Q.bind(this,h,Ae),setChannelMetadata:Q.bind(this,h,ke),removeChannelMetadata:Q.bind(this,h,Ce),getChannelMembers:Q.bind(this,h,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function hn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?hn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},vn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var h=zn(a,p);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},dr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(dr);var fr=pr,hr=dr.exports,yr=hr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),vr="function"==typeof Map&&Map.prototype,mr=Object.getOwnPropertyDescriptor&&vr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=vr&&mr&&"function"==typeof mr.get?mr.get:null,_r=vr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?hr(n):n},vo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var d=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var h=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,f);return"[Function"+(h?": "+h:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var v="<"+Ur.call(String(t.nodeName)),m=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,f);return d&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,d)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,d)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,d)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":d?k+"{"+fo(P,d)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},mo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?m.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(m);O=c?E.sort(c):E}for(var T=o&&Ho(m)&&1===m.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+d:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const di=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&di.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const hi=ai;var yi=gi;function gi(){}function vi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function mi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function v(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&m(t,n,e[n]);return t.join("&")}function m(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){m(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&m(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=v,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,d.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=v(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||h,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:m(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:v(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return hn(d.decode(e))}),v),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(dn);return Bi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var d=h.exports,y=function(){return d.uuid?d.uuid():d()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,h=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=f,64!=l&&(o[s+1]=h),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),f=2;f<=p;f++)if(!(l%f)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var h=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],f=0;64>f;f++){if(16>f)h[f]=0|e[t+f];else{var d=h[f-15],y=h[f-2];h[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+h[f-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+h[f-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+h[f],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],f=e[i+4],h=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,f,7,c[4]),E=t(E,P,A,T,h,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,h,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,f,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,h,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,f,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,h,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,f,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(u=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),h=(h.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:h}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,f.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],f=[],h=[],d=0;256>d;d++)h[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=h[y],b=h[v],_=h[b],S=257*h[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,f[m]=S,y?(y=v^h[h[h[_^v]]],g^=h[h[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,f,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],f=e[t+3]^n[3],h=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[f>>>8&255]^a[255&c]^n[h++],m=r[p>>>24]^o[f>>>16&255]^i[c>>>8&255]^a[255&l]^n[h++];f=r[f>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[f>>>8&255]<<8|s[255&c])^n[h++],m=(s[p>>>24]<<24|s[f>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,f=r(u,["uuid","channel"]);f.user=l,f.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:f})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var h=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(h=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=h.message,y.file={id:h.file.id,name:h.file.name,url:o._getFileUrl({id:h.file.id,name:h.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,f=i.length>0;(l||p||f)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),f&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var h=a.length>0,d=s.length>0,y=u.length>0;return(h||d||y)&&(c.patterns={},h&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,f=e.file,h=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!f)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(f),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&f.uri?(A=(T=p).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:h,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&f.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&f.include.push("uuid")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&f.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&f.include.push("channel")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,f=void 0!==p&&p,h=t.manage,d=void 0!==h&&h,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=f?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,f=o.spaces,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,f=o.channels,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),f=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),h=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||h||p||d||f||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,f=t.includeUUID,h=void 0===f||f,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),h&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],f=l[1],h=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=f,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:f,event:e});try{for(var b=a(h),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){return Ft.with(n(n({},e),{cursor:t.payload.cursor}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ht(e)})),Ut.onExit((function(){return ht.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ft({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ft({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return(null==t?void 0:t.retryAfter)?1e3*t.retryAfter:1e3*(this.delay+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){if(null==t?void 0:t.retryAfter)return 1e3*t.retryAfter;var n=1e3*(Math.pow(2,e)+Math.random());return n>this.maximumDelay?this.maximumDelay:n},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var f=e.payload;if(this.modules.cryptoModule){var h=void 0;try{h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=f.message,a.file={id:f.file.id,name:f.file.name,url:this.getFileUrl({id:f.file.id,name:f.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){h=void 0;try{var d;h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=h?h:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),fn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var f=new I({maximumSamplesCount:6e4});this._telemetryManager=f;var h=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:f,PubNubFile:e.PubNubFile,cryptoModule:h};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,fe),this.removeMessageAction=Q.bind(this,d,he),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,ke),removeChannelMetadata:Q.bind(this,d,Ce),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},fr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(fr);var hr=pr,dr=fr.exports,yr=dr(hr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var f=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function h(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,h);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,h);return f&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,f)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,h);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+h(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(h(n,t,!0)+" => "+h(e,t))})),po("Map",br.call(t),w,f)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(h(e,t))})),po("Set",Or.call(t),O,f)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(h(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,h),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":f?k+"{"+fo(P,f)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?h+f:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const fi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),hi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&hi.has(t.status))return!0;if(e){if(e.code&&fi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,f.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new h;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new hn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(f.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(fn);return Bi})); diff --git a/lib/event-engine/core/retryPolicy.js b/lib/event-engine/core/retryPolicy.js index 837bbb34d..4efb9bfca 100644 --- a/lib/event-engine/core/retryPolicy.js +++ b/lib/event-engine/core/retryPolicy.js @@ -10,12 +10,15 @@ var RetryPolicy = /** @class */ (function () { maximumRetry: configuration.maximumRetry, shouldRetry: function (error, attempt) { var _a; - if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { return false; } return this.maximumRetry > attempt; }, - getDelay: function (_) { + getDelay: function (_, reason) { + if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { + return reason.retryAfter * 1000; + } return (this.delay + Math.random()) * 1000; }, getGiveupReason: function (error, attempt) { @@ -23,8 +26,8 @@ var RetryPolicy = /** @class */ (function () { if (this.maximumRetry <= attempt) { return 'retry attempts exhaused.'; } - if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { - return 'forbidden or too many requests.'; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return 'forbidden operation.'; } return 'unknown error'; }, @@ -42,7 +45,10 @@ var RetryPolicy = /** @class */ (function () { } return this.maximumRetry > attempt; }, - getDelay: function (attempt) { + getDelay: function (attempt, reason) { + if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { + return reason.retryAfter * 1000; + } var calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; if (calculatedDelay > this.maximumDelay) { return this.maximumDelay; @@ -56,14 +62,13 @@ var RetryPolicy = /** @class */ (function () { if (this.maximumRetry <= attempt) { return 'retry attempts exhaused.'; } - if (RetryPolicy.excludedErrorCodes.includes((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode)) { - return 'forbidden or too many requests.'; + if (((_a = error === null || error === void 0 ? void 0 : error.status) === null || _a === void 0 ? void 0 : _a.statusCode) === 403) { + return 'forbidden operation.'; } return 'unknown error'; }, }; }; - RetryPolicy.excludedErrorCodes = [403, 429]; return RetryPolicy; }()); exports.RetryPolicy = RetryPolicy; diff --git a/lib/event-engine/dispatcher.js b/lib/event-engine/dispatcher.js index a41912cdc..27e5c02a9 100644 --- a/lib/event-engine/dispatcher.js +++ b/lib/event-engine/dispatcher.js @@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -86,7 +97,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _this.on(effects.handshake.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { var handshake = _a.handshake, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var handshakeParams, result, e_1; + var result, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -94,15 +105,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); - handshakeParams = { - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - }; - if (config.maintainPresenceState) - handshakeParams.state = presenceState; - return [4 /*yield*/, handshake(handshakeParams)]; + return [4 /*yield*/, handshake(__assign({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, filterExpression: config.filterExpression }, (config.maintainPresenceState && { state: presenceState })))]; case 2: result = _b.sent(); return [2 /*return*/, engine.transition(events.handshakeSuccess(result))]; @@ -186,7 +189,7 @@ var EventEngineDispatcher = /** @class */ (function (_super) { case 0: if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts, payload.reason))]; case 1: _b.sent(); abortSignal.throwIfAborted(); @@ -223,28 +226,20 @@ var EventEngineDispatcher = /** @class */ (function (_super) { _this.on(effects.handshakeReconnect.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { var handshake = _a.handshake, delay = _a.delay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var handshakeParams, result, error_3; + var result, error_3; return __generator(this, function (_b) { switch (_b.label) { case 0: if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts))]; + return [4 /*yield*/, delay(config.retryConfiguration.getDelay(payload.attempts, payload.reason))]; case 1: _b.sent(); abortSignal.throwIfAborted(); _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - handshakeParams = { - abortSignal: abortSignal, - channels: payload.channels, - channelGroups: payload.groups, - filterExpression: config.filterExpression, - }; - if (config.maintainPresenceState) - handshakeParams.state = presenceState; - return [4 /*yield*/, handshake(handshakeParams)]; + return [4 /*yield*/, handshake(__assign({ abortSignal: abortSignal, channels: payload.channels, channelGroups: payload.groups, filterExpression: config.filterExpression }, (config.maintainPresenceState && { state: presenceState })))]; case 3: result = _b.sent(); return [2 /*return*/, engine.transition(events.handshakeReconnectSuccess(result))]; diff --git a/lib/event-engine/events.js b/lib/event-engine/events.js index d33d16ab1..bcea70719 100644 --- a/lib/event-engine/events.js +++ b/lib/event-engine/events.js @@ -9,8 +9,10 @@ exports.subscriptionChange = (0, core_1.createEvent)('SUBSCRIPTION_CHANGED', fun exports.restore = (0, core_1.createEvent)('SUBSCRIPTION_RESTORED', function (channels, groups, timetoken, region) { return ({ channels: channels, groups: groups, - timetoken: timetoken, - region: region, + cursor: { + timetoken: timetoken, + region: region !== null && region !== void 0 ? region : 0, + }, }); }); exports.handshakeSuccess = (0, core_1.createEvent)('HANDSHAKE_SUCCESS', function (cursor) { return cursor; }); exports.handshakeFailure = (0, core_1.createEvent)('HANDSHAKE_FAILURE', function (error) { return error; }); @@ -32,7 +34,9 @@ exports.receiveReconnectFailure = (0, core_1.createEvent)('RECEIVE_RECONNECT_FAI exports.receiveReconnectGiveup = (0, core_1.createEvent)('RECEIVING_RECONNECT_GIVEUP', function (error) { return error; }); exports.disconnect = (0, core_1.createEvent)('DISCONNECT', function () { return ({}); }); exports.reconnect = (0, core_1.createEvent)('RECONNECT', function (timetoken, region) { return ({ - timetoken: timetoken, - region: region, + cursor: { + timetoken: timetoken !== null && timetoken !== void 0 ? timetoken : '', + region: region !== null && region !== void 0 ? region : 0, + }, }); }); exports.unsubscribeAll = (0, core_1.createEvent)('UNSUBSCRIBE_ALL', function () { return ({}); }); diff --git a/lib/event-engine/presence/dispatcher.js b/lib/event-engine/presence/dispatcher.js index 8ac69096f..2b79f44eb 100644 --- a/lib/event-engine/presence/dispatcher.js +++ b/lib/event-engine/presence/dispatcher.js @@ -101,18 +101,12 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { _this.on(effects.heartbeat.type, (0, core_1.asyncHandler)(function (payload, _, _a) { var heartbeat = _a.heartbeat, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var heartbeatParams, result, e_1; + var result, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: _b.trys.push([0, 2, , 3]); - heartbeatParams = { - channels: payload.channels, - channelGroups: payload.groups, - }; - if (config.maintainPresenceState) - heartbeatParams.state = presenceState; - return [4 /*yield*/, heartbeat(heartbeatParams)]; + return [4 /*yield*/, heartbeat(__assign({ channels: payload.channels, channelGroups: payload.groups }, (config.maintainPresenceState && { state: presenceState })))]; case 1: result = _b.sent(); engine.transition(events.heartbeatSuccess(200)); @@ -173,26 +167,20 @@ var PresenceEventEngineDispatcher = /** @class */ (function (_super) { _this.on(effects.delayedHeartbeat.type, (0, core_1.asyncHandler)(function (payload, abortSignal, _a) { var heartbeat = _a.heartbeat, retryDelay = _a.retryDelay, presenceState = _a.presenceState, config = _a.config; return __awaiter(_this, void 0, void 0, function () { - var heartbeatParams, result, e_3; + var result, e_3; return __generator(this, function (_b) { switch (_b.label) { case 0: if (!(config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts))) return [3 /*break*/, 6]; abortSignal.throwIfAborted(); - return [4 /*yield*/, retryDelay(config.retryConfiguration.getDelay(payload.attempts))]; + return [4 /*yield*/, retryDelay(config.retryConfiguration.getDelay(payload.attempts, payload.reason))]; case 1: _b.sent(); abortSignal.throwIfAborted(); _b.label = 2; case 2: _b.trys.push([2, 4, , 5]); - heartbeatParams = { - channels: payload.channels, - channelGroups: payload.groups, - }; - if (config.maintainPresenceState) - heartbeatParams.state = presenceState; - return [4 /*yield*/, heartbeat(heartbeatParams)]; + return [4 /*yield*/, heartbeat(__assign({ channels: payload.channels, channelGroups: payload.groups }, (config.maintainPresenceState && { state: presenceState })))]; case 3: result = _b.sent(); return [2 /*return*/, engine.transition(events.heartbeatSuccess(200))]; diff --git a/lib/event-engine/states/handshake_failed.js b/lib/event-engine/states/handshake_failed.js index a557af858..4b471dd30 100644 --- a/lib/event-engine/states/handshake_failed.js +++ b/lib/event-engine/states/handshake_failed.js @@ -10,24 +10,20 @@ exports.HandshakeFailedState.on(events_1.subscriptionChange.type, function (_, e return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); exports.HandshakeFailedState.on(events_1.reconnect.type, function (context, event) { - var _a, _b, _c, _d, _e; return handshaking_1.HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: { - timetoken: (_c = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.timetoken) !== null && _c !== void 0 ? _c : '0', - region: (_e = (_d = event.payload) === null || _d === void 0 ? void 0 : _d.region) !== null && _e !== void 0 ? _e : 0, - }, + cursor: context.cursor, }); }); -exports.HandshakeFailedState.on(events_1.restore.type, function (_, event) { +exports.HandshakeFailedState.on(events_1.restore.type, function (context, event) { var _a, _b; return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); diff --git a/lib/event-engine/states/handshake_reconnecting.js b/lib/event-engine/states/handshake_reconnecting.js index 3395d5070..829b1d4f8 100644 --- a/lib/event-engine/states/handshake_reconnecting.js +++ b/lib/event-engine/states/handshake_reconnecting.js @@ -28,9 +28,9 @@ exports.HandshakeReconnectingState = new state_1.State('HANDSHAKE_RECONNECTING') exports.HandshakeReconnectingState.onEnter(function (context) { return (0, effects_1.handshakeReconnect)(context); }); exports.HandshakeReconnectingState.onExit(function () { return effects_1.handshakeReconnect.cancel; }); exports.HandshakeReconnectingState.on(events_1.handshakeReconnectSuccess.type, function (context, event) { - var _a; + var _a, _b; var cursor = { - timetoken: (_a = context === null || context === void 0 ? void 0 : context.timetoken) !== null && _a !== void 0 ? _a : event.payload.cursor.timetoken, + timetoken: !!((_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) ? (_b = context.cursor) === null || _b === void 0 ? void 0 : _b.timetoken : event.payload.cursor.timetoken, region: event.payload.cursor.region, }; return receiving_1.ReceivingState.with({ @@ -47,32 +47,28 @@ exports.HandshakeReconnectingState.on(events_1.handshakeReconnectGiveup.type, fu return handshake_failed_1.HandshakeFailedState.with({ groups: context.groups, channels: context.channels, - timetoken: context.timetoken, + cursor: context.cursor, reason: event.payload, }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNConnectionErrorCategory, error: (_a = event.payload) === null || _a === void 0 ? void 0 : _a.message })]); }); exports.HandshakeReconnectingState.on(events_1.disconnect.type, function (context) { - var _a; return handshake_stopped_1.HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, - cursor: { - timetoken: (_a = context.timetoken) !== null && _a !== void 0 ? _a : '0', - region: 0, - }, + cursor: context.cursor, }); }); exports.HandshakeReconnectingState.on(events_1.subscriptionChange.type, function (_, event) { return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); }); -exports.HandshakeReconnectingState.on(events_1.restore.type, function (_, event) { +exports.HandshakeReconnectingState.on(events_1.restore.type, function (context, event) { var _a, _b; return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); diff --git a/lib/event-engine/states/handshake_stopped.js b/lib/event-engine/states/handshake_stopped.js index 177c7ad70..720fb7149 100644 --- a/lib/event-engine/states/handshake_stopped.js +++ b/lib/event-engine/states/handshake_stopped.js @@ -25,20 +25,16 @@ exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (con }); }); exports.HandshakeStoppedState.on(events_1.reconnect.type, function (context, event) { - var _a, _b, _c, _d, _e, _f; - return handshaking_1.HandshakingState.with(__assign(__assign({}, context), { cursor: { - timetoken: (_d = (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : (_c = context.cursor) === null || _c === void 0 ? void 0 : _c.timetoken) !== null && _d !== void 0 ? _d : '0', - region: (_f = (_e = event.payload) === null || _e === void 0 ? void 0 : _e.region) !== null && _f !== void 0 ? _f : 0, - } })); + return handshaking_1.HandshakingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor })); }); -exports.HandshakeStoppedState.on(events_1.restore.type, function (_, event) { +exports.HandshakeStoppedState.on(events_1.restore.type, function (context, event) { var _a, _b; return exports.HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); diff --git a/lib/event-engine/states/handshaking.js b/lib/event-engine/states/handshaking.js index e6c123cd5..dd5833d91 100644 --- a/lib/event-engine/states/handshaking.js +++ b/lib/event-engine/states/handshaking.js @@ -27,7 +27,7 @@ exports.HandshakingState.on(events_1.handshakeSuccess.type, function (context, e channels: context.channels, groups: context.groups, cursor: { - timetoken: (_b = (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : event.payload.timetoken, + timetoken: !!((_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken) ? (_b = context === null || context === void 0 ? void 0 : context.cursor) === null || _b === void 0 ? void 0 : _b.timetoken : event.payload.timetoken, region: event.payload.region, }, }, [ @@ -37,11 +37,10 @@ exports.HandshakingState.on(events_1.handshakeSuccess.type, function (context, e ]); }); exports.HandshakingState.on(events_1.handshakeFailure.type, function (context, event) { - var _a; return handshake_reconnecting_1.HandshakeReconnectingState.with({ channels: context.channels, groups: context.groups, - timetoken: (_a = context.cursor) === null || _a === void 0 ? void 0 : _a.timetoken, + cursor: context.cursor, attempts: 0, reason: event.payload, }); @@ -50,16 +49,17 @@ exports.HandshakingState.on(events_1.disconnect.type, function (context) { return handshake_stopped_1.HandshakeStoppedState.with({ channels: context.channels, groups: context.groups, + cursor: context.cursor, }); }); -exports.HandshakingState.on(events_1.restore.type, function (_, event) { +exports.HandshakingState.on(events_1.restore.type, function (context, event) { var _a, _b; return exports.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, }, }); }); diff --git a/lib/event-engine/states/receive_failed.js b/lib/event-engine/states/receive_failed.js index b1473bf0d..035a80f0b 100644 --- a/lib/event-engine/states/receive_failed.js +++ b/lib/event-engine/states/receive_failed.js @@ -7,13 +7,13 @@ var handshaking_1 = require("./handshaking"); var unsubscribed_1 = require("./unsubscribed"); exports.ReceiveFailedState = new state_1.State('RECEIVE_FAILED'); exports.ReceiveFailedState.on(events_1.reconnect.type, function (context, event) { - var _a, _b, _c, _d; + var _a; return handshaking_1.HandshakingState.with({ channels: context.channels, groups: context.groups, cursor: { - timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : '0', - region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : 0, + timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); @@ -23,12 +23,14 @@ exports.ReceiveFailedState.on(events_1.subscriptionChange.type, function (_, eve groups: event.payload.groups, }); }); -exports.ReceiveFailedState.on(events_1.restore.type, function (_, event) { - var _a, _b; +exports.ReceiveFailedState.on(events_1.restore.type, function (context, event) { return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: { timetoken: event.payload.timetoken, region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0 }, + cursor: { + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + }, }); }); exports.ReceiveFailedState.on(events_1.unsubscribeAll.type, function (_) { return unsubscribed_1.UnsubscribedState.with(undefined); }); diff --git a/lib/event-engine/states/receive_reconnecting.js b/lib/event-engine/states/receive_reconnecting.js index 20877cc75..b7dc98dab 100644 --- a/lib/event-engine/states/receive_reconnecting.js +++ b/lib/event-engine/states/receive_reconnecting.js @@ -53,13 +53,12 @@ exports.ReceiveReconnectingState.on(events_1.disconnect.type, function (context) }, [(0, effects_1.emitStatus)({ category: categories_1.default.PNDisconnectedCategory })]); }); exports.ReceiveReconnectingState.on(events_1.restore.type, function (context, event) { - var _a, _b; return receiving_1.ReceivingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); diff --git a/lib/event-engine/states/receive_stopped.js b/lib/event-engine/states/receive_stopped.js index 1b49d352a..09728a734 100644 --- a/lib/event-engine/states/receive_stopped.js +++ b/lib/event-engine/states/receive_stopped.js @@ -14,24 +14,23 @@ exports.ReceiveStoppedState.on(events_1.subscriptionChange.type, function (conte }); }); exports.ReceiveStoppedState.on(events_1.restore.type, function (context, event) { - var _a, _b; return exports.ReceiveStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); exports.ReceiveStoppedState.on(events_1.reconnect.type, function (context, event) { - var _a, _b, _c, _d; + var _a; return handshaking_1.HandshakingState.with({ channels: context.channels, groups: context.groups, cursor: { - timetoken: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.timetoken) !== null && _b !== void 0 ? _b : context.cursor.timetoken, - region: (_d = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.region) !== null && _d !== void 0 ? _d : context.cursor.region, + timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); diff --git a/lib/event-engine/states/receiving.js b/lib/event-engine/states/receiving.js index ba951310b..e90ad8e19 100644 --- a/lib/event-engine/states/receiving.js +++ b/lib/event-engine/states/receiving.js @@ -41,7 +41,6 @@ exports.ReceivingState.on(events_1.subscriptionChange.type, function (context, e }); }); exports.ReceivingState.on(events_1.restore.type, function (context, event) { - var _a, _b; if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { return unsubscribed_1.UnsubscribedState.with(undefined); } @@ -49,8 +48,8 @@ exports.ReceivingState.on(events_1.restore.type, function (context, event) { channels: event.payload.channels, groups: event.payload.groups, cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : context.cursor.region, + timetoken: event.payload.cursor.timetoken, + region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, }, }); }); diff --git a/lib/event-engine/states/unsubscribed.js b/lib/event-engine/states/unsubscribed.js index 90debb100..e5076d50c 100644 --- a/lib/event-engine/states/unsubscribed.js +++ b/lib/event-engine/states/unsubscribed.js @@ -12,13 +12,9 @@ exports.UnsubscribedState.on(events_1.subscriptionChange.type, function (_, even }); }); exports.UnsubscribedState.on(events_1.restore.type, function (_, event) { - var _a, _b; return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, - cursor: { - timetoken: event.payload.timetoken, - region: (_b = (_a = event.payload) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, - }, + cursor: event.payload.cursor, }); }); From a428e1ee4a3e382ae8697d8a91fbe3e4c6b1dc28 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 13:48:27 +0530 Subject: [PATCH 52/63] refactor: reconnect event handling --- dist/web/pubnub.js | 4 ++-- dist/web/pubnub.min.js | 2 +- lib/event-engine/states/handshake_failed.js | 2 +- lib/event-engine/states/handshake_stopped.js | 2 +- src/event-engine/states/handshake_failed.ts | 2 +- src/event-engine/states/handshake_stopped.ts | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index fcfc6e7e2..ba733364a 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -7375,7 +7375,7 @@ return HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: context.cursor, + cursor: context.cursor || event.payload.cursor, }); }); HandshakeFailedState.on(restore.type, function (context, event) { @@ -7400,7 +7400,7 @@ }); }); HandshakeStoppedState.on(reconnect$1.type, function (context, event) { - return HandshakingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor })); + return HandshakingState.with(__assign(__assign({}, context), { cursor: context.cursor || event.payload.cursor })); }); HandshakeStoppedState.on(restore.type, function (context, event) { var _a, _b; diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index 65a94ad05..abdecfac7 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -14,4 +14,4 @@ PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return f(3,o.length),p(o);default:var h;if(Array.isArray(t))for(f(4,h=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,f,m=l(),v=m>>5,b=31&m;if(7===v)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((f=d(b))<0&&(v<2||6=0;)S+=f,_.push(c(f));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(f);case 3:var P=[];if(f<0)for(;(f=y(v))>=0;)g(P,f);else g(P,f);return String.fromCharCode.apply(null,P);case 4:var E;if(f<0)for(E=[];!h();)E.push(e());else for(E=new Array(f),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,h=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=f,64!=l&&(o[s+1]=h),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),f=2;f<=p;f++)if(!(l%f)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var h=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],f=0;64>f;f++){if(16>f)h[f]=0|e[t+f];else{var d=h[f-15],y=h[f-2];h[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+h[f-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+h[f-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+h[f],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],f=e[i+4],h=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,f,7,c[4]),E=t(E,P,A,T,h,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,h,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,f,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,h,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,f,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,h,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,f,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(u=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),h=(h.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:h}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,f.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],f=[],h=[],d=0;256>d;d++)h[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=h[y],b=h[v],_=h[b],S=257*h[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,f[m]=S,y?(y=v^h[h[h[_^v]]],g^=h[h[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,f,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],f=e[t+3]^n[3],h=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[f>>>8&255]^a[255&c]^n[h++],m=r[p>>>24]^o[f>>>16&255]^i[c>>>8&255]^a[255&l]^n[h++];f=r[f>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[f>>>8&255]<<8|s[255&c])^n[h++],m=(s[p>>>24]<<24|s[f>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,f=r(u,["uuid","channel"]);f.user=l,f.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:f})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var h=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(h=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=h.message,y.file={id:h.file.id,name:h.file.name,url:o._getFileUrl({id:h.file.id,name:h.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,f=i.length>0;(l||p||f)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),f&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var h=a.length>0,d=s.length>0,y=u.length>0;return(h||d||y)&&(c.patterns={},h&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,f=e.file,h=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!f)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(f),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&f.uri?(A=(T=p).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:h,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&f.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&f.include.push("uuid")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&f.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&f.include.push("channel")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,f=void 0!==p&&p,h=t.manage,d=void 0!==h&&h,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=f?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,f=o.spaces,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,f=o.channels,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),f=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),h=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||h||p||d||f||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,f=t.includeUUID,h=void 0===f||f,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),h&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],f=l[1],h=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=f,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:f,event:e});try{for(var b=a(h),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){return Ft.with(n(n({},e),{cursor:t.payload.cursor}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ht(e)})),Ut.onExit((function(){return ht.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ft({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ft({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return(null==t?void 0:t.retryAfter)?1e3*t.retryAfter:1e3*(this.delay+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){if(null==t?void 0:t.retryAfter)return 1e3*t.retryAfter;var n=1e3*(Math.pow(2,e)+Math.random());return n>this.maximumDelay?this.maximumDelay:n},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var f=e.payload;if(this.modules.cryptoModule){var h=void 0;try{h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=f.message,a.file={id:f.file.id,name:f.file.name,url:this.getFileUrl({id:f.file.id,name:f.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){h=void 0;try{var d;h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=h?h:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),fn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var f=new I({maximumSamplesCount:6e4});this._telemetryManager=f;var h=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:f,PubNubFile:e.PubNubFile,cryptoModule:h};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,fe),this.removeMessageAction=Q.bind(this,d,he),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,ke),removeChannelMetadata:Q.bind(this,d,Ce),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},fr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(fr);var hr=pr,dr=fr.exports,yr=dr(hr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var f=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function h(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,h);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,h);return f&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,f)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,h);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+h(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(h(n,t,!0)+" => "+h(e,t))})),po("Map",br.call(t),w,f)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(h(e,t))})),po("Set",Or.call(t),O,f)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(h(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,h),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":f?k+"{"+fo(P,f)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?h+f:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const fi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),hi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&hi.has(t.status))return!0;if(e){if(e.code&&fi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,f.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new h;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new hn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(f.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(fn);return Bi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(h,h.exports);var d=h.exports,y=function(){return d.uuid?d.uuid():d()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,h=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=f,64!=l&&(o[s+1]=h),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),f=2;f<=p;f++)if(!(l%f)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var h=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],f=0;64>f;f++){if(16>f)h[f]=0|e[t+f];else{var d=h[f-15],y=h[f-2];h[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+h[f-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+h[f-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+h[f],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],f=e[i+4],h=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,f,7,c[4]),E=t(E,P,A,T,h,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,h,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,f,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,h,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,f,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,h,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,f,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(u=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),h=(h.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:h}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,f.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],f=[],h=[],d=0;256>d;d++)h[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=h[y],b=h[v],_=h[b],S=257*h[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,f[m]=S,y?(y=v^h[h[h[_^v]]],g^=h[h[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,f,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],f=e[t+3]^n[3],h=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[f>>>8&255]^a[255&c]^n[h++],m=r[p>>>24]^o[f>>>16&255]^i[c>>>8&255]^a[255&l]^n[h++];f=r[f>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[f>>>8&255]<<8|s[255&c])^n[h++],m=(s[p>>>24]<<24|s[f>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,f=r(u,["uuid","channel"]);f.user=l,f.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:f})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var h=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(h=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=h.message,y.file={id:h.file.id,name:h.file.name,url:o._getFileUrl({id:h.file.id,name:h.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,f=i.length>0;(l||p||f)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),f&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var h=a.length>0,d=s.length>0,y=u.length>0;return(h||d||y)&&(c.patterns={},h&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,f=e.file,h=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!f)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(f),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&f.uri?(A=(T=p).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:h,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&f.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&f.include.push("uuid")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&f.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&f.include.push("channel")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,f=void 0!==p&&p,h=t.manage,d=void 0!==h&&h,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=f?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,f=o.spaces,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,f=o.channels,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),f=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),h=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||h||p||d||f||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,f=t.includeUUID,h=void 0===f||f,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),h&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],f=l[1],h=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=f,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:f,event:e});try{for(var b=a(h),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:e.cursor||t.payload.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){return Ft.with(n(n({},e),{cursor:e.cursor||t.payload.cursor}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ht(e)})),Ut.onExit((function(){return ht.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ft({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ft({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return(null==t?void 0:t.retryAfter)?1e3*t.retryAfter:1e3*(this.delay+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){if(null==t?void 0:t.retryAfter)return 1e3*t.retryAfter;var n=1e3*(Math.pow(2,e)+Math.random());return n>this.maximumDelay?this.maximumDelay:n},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var f=e.payload;if(this.modules.cryptoModule){var h=void 0;try{h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=f.message,a.file={id:f.file.id,name:f.file.name,url:this.getFileUrl({id:f.file.id,name:f.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){h=void 0;try{var d;h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=h?h:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),fn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var f=new I({maximumSamplesCount:6e4});this._telemetryManager=f;var h=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:f,PubNubFile:e.PubNubFile,cryptoModule:h};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,fe),this.removeMessageAction=Q.bind(this,d,he),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,ke),removeChannelMetadata:Q.bind(this,d,Ce),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},fr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(fr);var hr=pr,dr=fr.exports,yr=dr(hr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var f=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function h(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,h);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,h);return f&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,f)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,h);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+h(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(h(n,t,!0)+" => "+h(e,t))})),po("Map",br.call(t),w,f)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(h(e,t))})),po("Set",Or.call(t),O,f)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(h(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,h),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":f?k+"{"+fo(P,f)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?h+f:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const fi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),hi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&hi.has(t.status))return!0;if(e){if(e.code&&fi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,f.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new h;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new hn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(f.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(fn);return Bi})); diff --git a/lib/event-engine/states/handshake_failed.js b/lib/event-engine/states/handshake_failed.js index 4b471dd30..4a063ad10 100644 --- a/lib/event-engine/states/handshake_failed.js +++ b/lib/event-engine/states/handshake_failed.js @@ -13,7 +13,7 @@ exports.HandshakeFailedState.on(events_1.reconnect.type, function (context, even return handshaking_1.HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: context.cursor, + cursor: context.cursor || event.payload.cursor, }); }); exports.HandshakeFailedState.on(events_1.restore.type, function (context, event) { diff --git a/lib/event-engine/states/handshake_stopped.js b/lib/event-engine/states/handshake_stopped.js index 720fb7149..289731f72 100644 --- a/lib/event-engine/states/handshake_stopped.js +++ b/lib/event-engine/states/handshake_stopped.js @@ -25,7 +25,7 @@ exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (con }); }); exports.HandshakeStoppedState.on(events_1.reconnect.type, function (context, event) { - return handshaking_1.HandshakingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor })); + return handshaking_1.HandshakingState.with(__assign(__assign({}, context), { cursor: context.cursor || event.payload.cursor })); }); exports.HandshakeStoppedState.on(events_1.restore.type, function (context, event) { var _a, _b; diff --git a/src/event-engine/states/handshake_failed.ts b/src/event-engine/states/handshake_failed.ts index f270edf00..5b40dc3b7 100644 --- a/src/event-engine/states/handshake_failed.ts +++ b/src/event-engine/states/handshake_failed.ts @@ -24,7 +24,7 @@ HandshakeFailedState.on(reconnect.type, (context, event) => HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: context.cursor, + cursor: context.cursor || event.payload.cursor, }), ); diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index 115393631..9c6250049 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -24,7 +24,7 @@ HandshakeStoppedState.on(subscriptionChange.type, (context, event) => HandshakeStoppedState.on(reconnect.type, (context, event) => HandshakingState.with({ ...context, - cursor: event.payload.cursor, + cursor: context.cursor || event.payload.cursor, }), ); From d5e88d75a1bc0a697500d401510a8f7100f96000 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 15:44:54 +0530 Subject: [PATCH 53/63] getSubscribedChannels and channelGroups binding when eventEngine is enabled --- dist/web/pubnub.js | 8 ++++++++ dist/web/pubnub.min.js | 4 ++-- lib/core/pubnub-common.js | 2 ++ lib/event-engine/index.js | 6 ++++++ src/core/pubnub-common.js | 2 ++ src/event-engine/index.ts | 8 ++++++++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index ba733364a..bbaf7f08d 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -7775,6 +7775,12 @@ this.dependencies.leaveAll(); } }; + EventEngine.prototype.getSubscribedChannels = function () { + return this.channels.slice(0); + }; + EventEngine.prototype.getSubscribedChannelGroups = function () { + return this.groups.slice(0); + }; EventEngine.prototype.dispose = function () { this.disconnect(); this._unsubscribeEngine(); @@ -8531,6 +8537,8 @@ this.reconnect = eventEngine.reconnect.bind(eventEngine); this.disconnect = eventEngine.disconnect.bind(eventEngine); this.destroy = eventEngine.dispose.bind(eventEngine); + this.getSubscribedChannels = eventEngine.getSubscribedChannels.bind(eventEngine); + this.getSubscribedChannelGroups = eventEngine.getSubscribedChannelGroups.bind(eventEngine); this.eventEngine = eventEngine; } else { diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index abdecfac7..adc4a358c 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -12,6 +12,6 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return f(3,o.length),p(o);default:var h;if(Array.isArray(t))for(f(4,h=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,f,m=l(),v=m>>5,b=31&m;if(7===v)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((f=d(b))<0&&(v<2||6=0;)S+=f,_.push(c(f));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(f);case 3:var P=[];if(f<0)for(;(f=y(v))>=0;)g(P,f);else g(P,f);return String.fromCharCode.apply(null,P);case 4:var E;if(f<0)for(E=[];!h();)E.push(e());else for(E=new Array(f),o=0;o0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),p(o);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,h,m=l(),v=m>>5,b=31&m;if(7===v)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(b))<0&&(v<2||6=0;)S+=h,_.push(c(h));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(h);case 3:var P=[];if(h<0)for(;(h=y(v))>=0;)g(P,h);else g(P,h);return String.fromCharCode.apply(null,P);case 4:var E;if(h<0)for(E=[];!f();)E.push(e());else for(E=new Array(h),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,h=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=f,64!=l&&(o[s+1]=h),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),f=2;f<=p;f++)if(!(l%f)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var h=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],f=0;64>f;f++){if(16>f)h[f]=0|e[t+f];else{var d=h[f-15],y=h[f-2];h[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+h[f-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+h[f-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[f]+h[f],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],f=e[i+4],h=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,f,7,c[4]),E=t(E,P,A,T,h,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,h,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,f,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,h,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,f,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,h,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,f,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(u=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),h=(h.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:h}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=f.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,f.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],f=[],h=[],d=0;256>d;d++)h[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=h[y],b=h[v],_=h[b],S=257*h[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,f[m]=S,y?(y=v^h[h[h[_^v]]],g^=h[h[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,f,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],f=e[t+3]^n[3],h=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&f]^n[h++],g=r[l>>>24]^o[p>>>16&255]^i[f>>>8&255]^a[255&c]^n[h++],m=r[p>>>24]^o[f>>>16&255]^i[c>>>8&255]^a[255&l]^n[h++];f=r[f>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[h++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&f])^n[h++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[f>>>8&255]<<8|s[255&c])^n[h++],m=(s[p>>>24]<<24|s[f>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[h++],f=(s[f>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[h++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=f},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,f=r(u,["uuid","channel"]);f.user=l,f.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:f})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var h=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(h=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=h.message,y.file={id:h.file.id,name:h.file.name,url:o._getFileUrl({id:h.file.id,name:h.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,f=i.length>0;(l||p||f)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),f&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var h=a.length>0,d=s.length>0,y=u.length>0;return(h||d||y)&&(c.patterns={},h&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,f=e.file,h=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,k,C,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!f)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(f),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&f.uri?(A=(T=p).POSTFILE,k=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,k.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(C=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(C,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:h,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),f.include=f.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(f.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(f.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(f.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),f.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&f.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&f.include.push("uuid")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f,h,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(f=t.page)||void 0===f?void 0:f.next),(null===(h=null==t?void 0:t.page)||void 0===h?void 0:h.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,f={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&f.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&f.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&f.include.push("channel")),f.include=f.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(f.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(f.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(f.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(f.filter=t.filter),null!=t.limit&&(f.limit=t.limit),(null==t?void 0:t.sort)&&(f.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),f},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,f=void 0!==p&&p,h=t.manage,d=void 0!==h&&h,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=f?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,f=o.spaces,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,f=o.channels,h=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.channels[e]=De(f[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.groups[e]=De(h[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),f=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),h=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||h||p||d||f||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,f=t.includeUUID,h=void 0===f||f,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),h&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],f=l[1],h=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=f,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:f,event:e});try{for(var b=a(h),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(kt.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:e.cursor||t.payload.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(Ct.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(kt.type,(function(e,t){return Ft.with(n(n({},e),{cursor:e.cursor||t.payload.cursor}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(Ct.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(Ct.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(kt.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(Ct.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ht(e)})),Ut.onExit((function(){return ht.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ft({category:R.PNDisconnectedCategory})])})),It.on(Ct.type,(function(e){return Gt.with(void 0,[ft({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ft({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ft({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(Ct.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ft({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(Ct.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(kt(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return(null==t?void 0:t.retryAfter)?1e3*t.retryAfter:1e3*(this.delay+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){if(null==t?void 0:t.retryAfter)return 1e3*t.retryAfter;var n=1e3*(Math.pow(2,e)+Math.random());return n>this.maximumDelay?this.maximumDelay:n},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var f=e.payload;if(this.modules.cryptoModule){var h=void 0;try{h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==h&&(f=h)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=f.message,a.file={id:f.file.id,name:f.file.name,url:this.getFileUrl({id:f.file.id,name:f.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){h=void 0;try{var d;h=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){h=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=h?h:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),fn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var f=new I({maximumSamplesCount:6e4});this._telemetryManager=f;var h=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:f,PubNubFile:e.PubNubFile,cryptoModule:h};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,fe),this.removeMessageAction=Q.bind(this,d,he),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,ke),removeChannelMetadata:Q.bind(this,d,Ce),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function kn(e,t,n,r){void 0===r&&(r=On());var o,i=Cn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function Cn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},fr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(fr);var hr=pr,dr=fr.exports,yr=dr(hr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,kr=Boolean.prototype.valueOf,Cr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return Cr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?fo(n,r):Fr.call(n,", "))+"}"}function fo(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function ho(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var f=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function h(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=ho(t,h);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=ho(t,h);return f&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+fo(_,f)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=ho(t,h);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+h(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(h(n,t,!0)+" => "+h(e,t))})),po("Map",br.call(t),w,f)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(h(e,t))})),po("Set",Or.call(t),O,f)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(h(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(kr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(h(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=ho(t,h),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",k=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?k+"{}":f?k+"{"+fo(P,f)+"}":k+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},ko=String.prototype.replace,Co=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return ko.call(e,Co,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?h+f:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const fi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),hi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&hi.has(t.status))return!0;if(e){if(e.code&&fi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,f.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new h;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new hn({del:Mi,get:ki,post:Ci,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(f.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(fn);return Bi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(f,f.exports);var d=f.exports,y=function(){return d.uuid?d.uuid():d()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=h,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],h=e[i+4],f=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,h,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,h,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,h,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,h,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=f[y],b=f[v],_=f[b],S=257*f[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,h[m]=S,y?(y=v^f[f[f[_^v]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^h[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,h,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&h]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[h>>>8&255]^a[255&c]^n[f++],m=r[p>>>24]^o[h>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];h=r[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&h])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^n[f++],m=(s[p>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,h=i.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,d=s.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,h=e.file,f=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,C,k,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!h)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(h),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&h.uri?(A=(T=p).POSTFILE,C=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=h?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,h=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,h=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||d||h||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:h,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(Ct.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:e.cursor||t.payload.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(kt.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(Ct.type,(function(e,t){return Ft.with(n(n({},e),{cursor:e.cursor||t.payload.cursor}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(kt.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(kt.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(kt.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),It.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ht({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(kt.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ht({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(kt.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(Ct(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},e.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return(null==t?void 0:t.retryAfter)?1e3*t.retryAfter:1e3*(this.delay+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){if(null==t?void 0:t.retryAfter)return 1e3*t.retryAfter;var n=1e3*(Math.pow(2,e)+Math.random());return n>this.maximumDelay?this.maximumDelay:n},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var h=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(h=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=h.message,a.file={id:h.file.id,name:h.file.name,url:this.getFileUrl({id:h.file.id,name:h.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var d;f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var h=new I({maximumSamplesCount:6e4});this._telemetryManager=h;var f=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,he),this.removeMessageAction=Q.bind(this,d,fe),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function Cn(e,t,n,r){void 0===r&&(r=On());var o,i=kn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function kn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var fr=pr,dr=hr.exports,yr=dr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Cr=Boolean.prototype.valueOf,kr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return kr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Fr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function fo(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=fo(t,f);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=fo(t,f);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,h)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=fo(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,h)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,h)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(Cr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=fo(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":h?C+"{"+ho(P,h)+"}":C+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},Co=String.prototype.replace,ko=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return Co.call(e,ko,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+h:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,h.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:Ci,post:ki,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(h.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(hn);return Bi})); diff --git a/lib/core/pubnub-common.js b/lib/core/pubnub-common.js index b321cf59e..80e6d8562 100644 --- a/lib/core/pubnub-common.js +++ b/lib/core/pubnub-common.js @@ -271,6 +271,8 @@ var default_1 = /** @class */ (function () { this.reconnect = eventEngine.reconnect.bind(eventEngine); this.disconnect = eventEngine.disconnect.bind(eventEngine); this.destroy = eventEngine.dispose.bind(eventEngine); + this.getSubscribedChannels = eventEngine.getSubscribedChannels.bind(eventEngine); + this.getSubscribedChannelGroups = eventEngine.getSubscribedChannelGroups.bind(eventEngine); this.eventEngine = eventEngine; } else { diff --git a/lib/event-engine/index.js b/lib/event-engine/index.js index 3f563237b..1cd5fa289 100644 --- a/lib/event-engine/index.js +++ b/lib/event-engine/index.js @@ -139,6 +139,12 @@ var EventEngine = /** @class */ (function () { this.dependencies.leaveAll(); } }; + EventEngine.prototype.getSubscribedChannels = function () { + return this.channels.slice(0); + }; + EventEngine.prototype.getSubscribedChannelGroups = function () { + return this.groups.slice(0); + }; EventEngine.prototype.dispose = function () { this.disconnect(); this._unsubscribeEngine(); diff --git a/src/core/pubnub-common.js b/src/core/pubnub-common.js index 62bd1b7da..e187a1995 100644 --- a/src/core/pubnub-common.js +++ b/src/core/pubnub-common.js @@ -403,6 +403,8 @@ export default class { this.reconnect = eventEngine.reconnect.bind(eventEngine); this.disconnect = eventEngine.disconnect.bind(eventEngine); this.destroy = eventEngine.dispose.bind(eventEngine); + this.getSubscribedChannels = eventEngine.getSubscribedChannels.bind(eventEngine); + this.getSubscribedChannelGroups = eventEngine.getSubscribedChannelGroups.bind(eventEngine); this.eventEngine = eventEngine; } else { const subscriptionManager = new SubscriptionManager({ diff --git a/src/event-engine/index.ts b/src/event-engine/index.ts index 0f0e0263d..18b9cb9d4 100644 --- a/src/event-engine/index.ts +++ b/src/event-engine/index.ts @@ -108,6 +108,14 @@ export class EventEngine { } } + getSubscribedChannels() { + return this.channels.slice(0); + } + + getSubscribedChannelGroups() { + return this.groups.slice(0); + } + dispose() { this.disconnect(); this._unsubscribeEngine(); From 82e6438a1a6698baf28d0f97890b2fee2869de78 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 18:19:24 +0530 Subject: [PATCH 54/63] refactor: retry policy delay calculation --- src/event-engine/core/retryPolicy.ts | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/event-engine/core/retryPolicy.ts b/src/event-engine/core/retryPolicy.ts index d3ae9e6b3..a1692ca75 100644 --- a/src/event-engine/core/retryPolicy.ts +++ b/src/event-engine/core/retryPolicy.ts @@ -10,10 +10,8 @@ export class RetryPolicy { return this.maximumRetry > attempt; }, getDelay(_: number, reason: any) { - if (reason?.retryAfter) { - return reason.retryAfter * 1000; - } - return (this.delay + Math.random()) * 1000; + const delay = reason.retryAfter ?? this.delay; + return (delay + Math.random()) * 1000; }, getGiveupReason(error: any, attempt: number) { if (this.maximumRetry <= attempt) { @@ -41,15 +39,8 @@ export class RetryPolicy { }, getDelay(attempt: number, reason: any) { - if (reason?.retryAfter) { - return reason.retryAfter * 1000; - } - const calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; - if (calculatedDelay > this.maximumDelay) { - return this.maximumDelay; - } else { - return calculatedDelay; - } + const delay = reason.retryAfter ?? Math.min(Math.pow(2, attempt), this.maximumDelay); + return (delay + Math.random()) * 1000; }, getGiveupReason(error: any, attempt: number) { From 79fd10b605a32dd659f093ae1b3e115e417f45a5 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 18:20:28 +0530 Subject: [PATCH 55/63] handshake* states: handling cursor value across state and defaulting to 0 for region when context/event has undefined --- src/event-engine/states/handshake_failed.ts | 12 ++++++++---- src/event-engine/states/handshake_reconnecting.ts | 10 +++++++--- src/event-engine/states/handshake_stopped.ts | 4 ++-- src/event-engine/states/handshaking.ts | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/event-engine/states/handshake_failed.ts b/src/event-engine/states/handshake_failed.ts index 5b40dc3b7..dd86cd552 100644 --- a/src/event-engine/states/handshake_failed.ts +++ b/src/event-engine/states/handshake_failed.ts @@ -16,15 +16,19 @@ export type HandshakeFailedStateContext = { export const HandshakeFailedState = new State('HANDSHAKE_FAILED'); -HandshakeFailedState.on(subscriptionChange.type, (_, event) => { - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); -}); +HandshakeFailedState.on(subscriptionChange.type, (context, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }), +); HandshakeFailedState.on(reconnect.type, (context, event) => HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: context.cursor || event.payload.cursor, + cursor: event.payload.cursor || context.cursor, }), ); diff --git a/src/event-engine/states/handshake_reconnecting.ts b/src/event-engine/states/handshake_reconnecting.ts index 75a3c6cf1..75a2fe6d3 100644 --- a/src/event-engine/states/handshake_reconnecting.ts +++ b/src/event-engine/states/handshake_reconnecting.ts @@ -74,8 +74,12 @@ HandshakeReconnectingState.on(disconnect.type, (context) => }), ); -HandshakeReconnectingState.on(subscriptionChange.type, (_, event) => - HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }), +HandshakeReconnectingState.on(subscriptionChange.type, (context, event) => + HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }), ); HandshakeReconnectingState.on(restore.type, (context, event) => @@ -84,7 +88,7 @@ HandshakeReconnectingState.on(restore.type, (context, event) => groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context?.cursor?.region ?? 0, + region: event.payload.cursor?.region || context?.cursor?.region || 0, }, }), ); diff --git a/src/event-engine/states/handshake_stopped.ts b/src/event-engine/states/handshake_stopped.ts index 9c6250049..133451f93 100644 --- a/src/event-engine/states/handshake_stopped.ts +++ b/src/event-engine/states/handshake_stopped.ts @@ -24,7 +24,7 @@ HandshakeStoppedState.on(subscriptionChange.type, (context, event) => HandshakeStoppedState.on(reconnect.type, (context, event) => HandshakingState.with({ ...context, - cursor: context.cursor || event.payload.cursor, + cursor: event.payload.cursor || context.cursor, }), ); @@ -34,7 +34,7 @@ HandshakeStoppedState.on(restore.type, (context, event) => groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context?.cursor?.region ?? 0, + region: event.payload.cursor.region || context?.cursor?.region || 0, }, }), ); diff --git a/src/event-engine/states/handshaking.ts b/src/event-engine/states/handshaking.ts index a5a894b9b..0236a190b 100644 --- a/src/event-engine/states/handshaking.ts +++ b/src/event-engine/states/handshaking.ts @@ -77,7 +77,7 @@ HandshakingState.on(restore.type, (context, event) => groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context?.cursor?.region ?? 0, + region: event.payload.cursor.region || context?.cursor?.region || 0, }, }), ); From 1117a840c56a7d47898dcd935852134c3de173dd Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 18:21:02 +0530 Subject: [PATCH 56/63] receiv* states: handling cursor across states --- src/event-engine/states/receive_failed.ts | 4 ++-- src/event-engine/states/receive_reconnecting.ts | 2 +- src/event-engine/states/receive_stopped.ts | 4 ++-- src/event-engine/states/receiving.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/event-engine/states/receive_failed.ts b/src/event-engine/states/receive_failed.ts index 76fb1180e..0ca505ae4 100644 --- a/src/event-engine/states/receive_failed.ts +++ b/src/event-engine/states/receive_failed.ts @@ -22,7 +22,7 @@ ReceiveFailedState.on(reconnect.type, (context, event) => groups: context.groups, cursor: { timetoken: !!event.payload.cursor.timetoken ? event.payload.cursor?.timetoken : context.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }), ); @@ -40,7 +40,7 @@ ReceiveFailedState.on(restore.type, (context, event) => groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }), ); diff --git a/src/event-engine/states/receive_reconnecting.ts b/src/event-engine/states/receive_reconnecting.ts index 3e4251125..69b550558 100644 --- a/src/event-engine/states/receive_reconnecting.ts +++ b/src/event-engine/states/receive_reconnecting.ts @@ -78,7 +78,7 @@ ReceiveReconnectingState.on(restore.type, (context, event) => groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }), ); diff --git a/src/event-engine/states/receive_stopped.ts b/src/event-engine/states/receive_stopped.ts index 86a60d411..20993b80f 100644 --- a/src/event-engine/states/receive_stopped.ts +++ b/src/event-engine/states/receive_stopped.ts @@ -27,7 +27,7 @@ ReceiveStoppedState.on(restore.type, (context, event) => groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }), ); @@ -38,7 +38,7 @@ ReceiveStoppedState.on(reconnect.type, (context, event) => groups: context.groups, cursor: { timetoken: !!event.payload.cursor.timetoken ? event.payload.cursor?.timetoken : context.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }), ); diff --git a/src/event-engine/states/receiving.ts b/src/event-engine/states/receiving.ts index 8e2408991..e7789debc 100644 --- a/src/event-engine/states/receiving.ts +++ b/src/event-engine/states/receiving.ts @@ -54,7 +54,7 @@ ReceivingState.on(restore.type, (context, event) => { groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); From 0d4a6f3f205f278e0e959b90b9a1f0bdeceda9a7 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 18:21:19 +0530 Subject: [PATCH 57/63] lib/dist --- dist/web/pubnub.js | 62 +++++++++---------- dist/web/pubnub.min.js | 2 +- lib/event-engine/core/retryPolicy.js | 20 ++---- lib/event-engine/states/handshake_failed.js | 10 ++- .../states/handshake_reconnecting.js | 10 ++- lib/event-engine/states/handshake_stopped.js | 6 +- lib/event-engine/states/handshaking.js | 4 +- lib/event-engine/states/receive_failed.js | 4 +- .../states/receive_reconnecting.js | 2 +- lib/event-engine/states/receive_stopped.js | 4 +- lib/event-engine/states/receiving.js | 2 +- 11 files changed, 63 insertions(+), 63 deletions(-) diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index bbaf7f08d..32b994a64 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -7368,14 +7368,18 @@ }(Dispatcher)); var HandshakeFailedState = new State('HANDSHAKE_FAILED'); - HandshakeFailedState.on(subscriptionChange.type, function (_, event) { - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + HandshakeFailedState.on(subscriptionChange.type, function (context, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); }); HandshakeFailedState.on(reconnect$1.type, function (context, event) { return HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: context.cursor || event.payload.cursor, + cursor: event.payload.cursor || context.cursor, }); }); HandshakeFailedState.on(restore.type, function (context, event) { @@ -7400,16 +7404,16 @@ }); }); HandshakeStoppedState.on(reconnect$1.type, function (context, event) { - return HandshakingState.with(__assign(__assign({}, context), { cursor: context.cursor || event.payload.cursor })); + return HandshakingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor || context.cursor })); }); HandshakeStoppedState.on(restore.type, function (context, event) { - var _a, _b; + var _a; return HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + region: event.payload.cursor.region || ((_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) || 0, }, }); }); @@ -7423,7 +7427,7 @@ groups: context.groups, cursor: { timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -7439,7 +7443,7 @@ groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -7459,7 +7463,7 @@ groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -7470,7 +7474,7 @@ groups: context.groups, cursor: { timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -7511,7 +7515,7 @@ groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -7553,7 +7557,7 @@ groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -7605,8 +7609,12 @@ cursor: context.cursor, }); }); - HandshakeReconnectingState.on(subscriptionChange.type, function (_, event) { - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + HandshakeReconnectingState.on(subscriptionChange.type, function (context, event) { + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); }); HandshakeReconnectingState.on(restore.type, function (context, event) { var _a, _b; @@ -7615,7 +7623,7 @@ groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + region: ((_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.region) || ((_b = context === null || context === void 0 ? void 0 : context.cursor) === null || _b === void 0 ? void 0 : _b.region) || 0, }, }); }); @@ -7662,13 +7670,13 @@ }); }); HandshakingState.on(restore.type, function (context, event) { - var _a, _b; + var _a; return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + region: event.payload.cursor.region || ((_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) || 0, }, }); }); @@ -8166,10 +8174,9 @@ return this.maximumRetry > attempt; }, getDelay: function (_, reason) { - if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { - return reason.retryAfter * 1000; - } - return (this.delay + Math.random()) * 1000; + var _a; + var delay = (_a = reason.retryAfter) !== null && _a !== void 0 ? _a : this.delay; + return (delay + Math.random()) * 1000; }, getGiveupReason: function (error, attempt) { var _a; @@ -8196,16 +8203,9 @@ return this.maximumRetry > attempt; }, getDelay: function (attempt, reason) { - if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { - return reason.retryAfter * 1000; - } - var calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; - if (calculatedDelay > this.maximumDelay) { - return this.maximumDelay; - } - else { - return calculatedDelay; - } + var _a; + var delay = (_a = reason.retryAfter) !== null && _a !== void 0 ? _a : Math.min(Math.pow(2, attempt), this.maximumDelay); + return (delay + Math.random()) * 1000; }, getGiveupReason: function (error, attempt) { var _a; diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index adc4a358c..d9fa0ad78 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -14,4 +14,4 @@ PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),p(o);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,h,m=l(),v=m>>5,b=31&m;if(7===v)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(b))<0&&(v<2||6=0;)S+=h,_.push(c(h));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(h);case 3:var P=[];if(h<0)for(;(h=y(v))>=0;)g(P,h);else g(P,h);return String.fromCharCode.apply(null,P);case 4:var E;if(h<0)for(E=[];!f();)E.push(e());else for(E=new Array(h),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=h,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],h=e[i+4],f=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,h,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,h,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,h,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,h,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=f[y],b=f[v],_=f[b],S=257*f[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,h[m]=S,y?(y=v^f[f[f[_^v]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^h[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,h,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&h]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[h>>>8&255]^a[255&c]^n[f++],m=r[p>>>24]^o[h>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];h=r[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&h])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^n[f++],m=(s[p>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,h=i.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,d=s.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,h=e.file,f=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,C,k,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!h)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(h),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&h.uri?(A=(T=p).POSTFILE,C=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=h?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,h=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,h=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||d||h||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:h,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Mt.on(Ct.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:e.cursor||t.payload.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(kt.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(Ct.type,(function(e,t){return Ft.with(n(n({},e),{cursor:e.cursor||t.payload.cursor}))})),jt.on(gt.type,(function(e,t){var n,r;return jt.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),jt.on(kt.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Rt.on(kt.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),xt.on(kt.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region?t.payload.cursor.region:e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),It.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ht({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Dt.on(kt.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ht({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Ft.on(kt.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(Ct(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},e.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return(null==t?void 0:t.retryAfter)?1e3*t.retryAfter:1e3*(this.delay+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){if(null==t?void 0:t.retryAfter)return 1e3*t.retryAfter;var n=1e3*(Math.pow(2,e)+Math.random());return n>this.maximumDelay?this.maximumDelay:n},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var h=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(h=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=h.message,a.file={id:h.file.id,name:h.file.name,url:this.getFileUrl({id:h.file.id,name:h.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var d;f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var h=new I({maximumSamplesCount:6e4});this._telemetryManager=h;var f=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,he),this.removeMessageAction=Q.bind(this,d,fe),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function Cn(e,t,n,r){void 0===r&&(r=On());var o,i=kn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function kn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var fr=pr,dr=hr.exports,yr=dr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Cr=Boolean.prototype.valueOf,kr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return kr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Fr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function fo(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=fo(t,f);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=fo(t,f);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,h)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=fo(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,h)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,h)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(Cr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=fo(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":h?C+"{"+ho(P,h)+"}":C+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},Co=String.prototype.replace,ko=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return Co.call(e,ko,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+h:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,h.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:Ci,post:ki,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(h.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(hn);return Bi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(f,f.exports);var d=f.exports,y=function(){return d.uuid?d.uuid():d()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=h,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],h=e[i+4],f=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,h,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,h,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,h,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,h,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=f[y],b=f[v],_=f[b],S=257*f[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,h[m]=S,y?(y=v^f[f[f[_^v]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^h[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,h,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&h]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[h>>>8&255]^a[255&c]^n[f++],m=r[p>>>24]^o[h>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];h=r[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&h])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^n[f++],m=(s[p>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,h=i.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,d=s.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,h=e.file,f=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,C,k,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!h)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(h),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&h.uri?(A=(T=p).POSTFILE,C=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=h?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,h=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,h=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||d||h||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:h,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Mt.on(Ct.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(kt.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(Ct.type,(function(e,t){return Ft.with(n(n({},e),{cursor:t.payload.cursor||e.cursor}))})),jt.on(gt.type,(function(e,t){var n;return jt.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?void 0:n.region)||0}})})),jt.on(kt.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(kt.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(kt.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),It.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ht({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null===(n=t.payload.cursor)||void 0===n?void 0:n.region)||(null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.region)||0}})})),Dt.on(kt.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ht({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n;return Ft.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?void 0:n.region)||0}})})),Ft.on(kt.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(Ct(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},e.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:this.delay)+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var h=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(h=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=h.message,a.file={id:h.file.id,name:h.file.name,url:this.getFileUrl({id:h.file.id,name:h.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var d;f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var h=new I({maximumSamplesCount:6e4});this._telemetryManager=h;var f=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,he),this.removeMessageAction=Q.bind(this,d,fe),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function Cn(e,t,n,r){void 0===r&&(r=On());var o,i=kn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function kn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var fr=pr,dr=hr.exports,yr=dr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Cr=Boolean.prototype.valueOf,kr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return kr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Fr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function fo(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=fo(t,f);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=fo(t,f);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,h)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=fo(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,h)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,h)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(Cr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=fo(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":h?C+"{"+ho(P,h)+"}":C+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},Co=String.prototype.replace,ko=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return Co.call(e,ko,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+h:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,h.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:Ci,post:ki,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(h.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(hn);return Bi})); diff --git a/lib/event-engine/core/retryPolicy.js b/lib/event-engine/core/retryPolicy.js index 4efb9bfca..dde639271 100644 --- a/lib/event-engine/core/retryPolicy.js +++ b/lib/event-engine/core/retryPolicy.js @@ -16,10 +16,9 @@ var RetryPolicy = /** @class */ (function () { return this.maximumRetry > attempt; }, getDelay: function (_, reason) { - if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { - return reason.retryAfter * 1000; - } - return (this.delay + Math.random()) * 1000; + var _a; + var delay = (_a = reason.retryAfter) !== null && _a !== void 0 ? _a : this.delay; + return (delay + Math.random()) * 1000; }, getGiveupReason: function (error, attempt) { var _a; @@ -46,16 +45,9 @@ var RetryPolicy = /** @class */ (function () { return this.maximumRetry > attempt; }, getDelay: function (attempt, reason) { - if (reason === null || reason === void 0 ? void 0 : reason.retryAfter) { - return reason.retryAfter * 1000; - } - var calculatedDelay = (Math.pow(2, attempt) + Math.random()) * 1000; - if (calculatedDelay > this.maximumDelay) { - return this.maximumDelay; - } - else { - return calculatedDelay; - } + var _a; + var delay = (_a = reason.retryAfter) !== null && _a !== void 0 ? _a : Math.min(Math.pow(2, attempt), this.maximumDelay); + return (delay + Math.random()) * 1000; }, getGiveupReason: function (error, attempt) { var _a; diff --git a/lib/event-engine/states/handshake_failed.js b/lib/event-engine/states/handshake_failed.js index 4a063ad10..658ff855d 100644 --- a/lib/event-engine/states/handshake_failed.js +++ b/lib/event-engine/states/handshake_failed.js @@ -6,14 +6,18 @@ var events_1 = require("../events"); var handshaking_1 = require("./handshaking"); var unsubscribed_1 = require("./unsubscribed"); exports.HandshakeFailedState = new state_1.State('HANDSHAKE_FAILED'); -exports.HandshakeFailedState.on(events_1.subscriptionChange.type, function (_, event) { - return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); +exports.HandshakeFailedState.on(events_1.subscriptionChange.type, function (context, event) { + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); }); exports.HandshakeFailedState.on(events_1.reconnect.type, function (context, event) { return handshaking_1.HandshakingState.with({ channels: context.channels, groups: context.groups, - cursor: context.cursor || event.payload.cursor, + cursor: event.payload.cursor || context.cursor, }); }); exports.HandshakeFailedState.on(events_1.restore.type, function (context, event) { diff --git a/lib/event-engine/states/handshake_reconnecting.js b/lib/event-engine/states/handshake_reconnecting.js index 829b1d4f8..9f5339e73 100644 --- a/lib/event-engine/states/handshake_reconnecting.js +++ b/lib/event-engine/states/handshake_reconnecting.js @@ -58,8 +58,12 @@ exports.HandshakeReconnectingState.on(events_1.disconnect.type, function (contex cursor: context.cursor, }); }); -exports.HandshakeReconnectingState.on(events_1.subscriptionChange.type, function (_, event) { - return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); +exports.HandshakeReconnectingState.on(events_1.subscriptionChange.type, function (context, event) { + return handshaking_1.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); }); exports.HandshakeReconnectingState.on(events_1.restore.type, function (context, event) { var _a, _b; @@ -68,7 +72,7 @@ exports.HandshakeReconnectingState.on(events_1.restore.type, function (context, groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + region: ((_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.region) || ((_b = context === null || context === void 0 ? void 0 : context.cursor) === null || _b === void 0 ? void 0 : _b.region) || 0, }, }); }); diff --git a/lib/event-engine/states/handshake_stopped.js b/lib/event-engine/states/handshake_stopped.js index 289731f72..3e2838fb9 100644 --- a/lib/event-engine/states/handshake_stopped.js +++ b/lib/event-engine/states/handshake_stopped.js @@ -25,16 +25,16 @@ exports.HandshakeStoppedState.on(events_1.subscriptionChange.type, function (con }); }); exports.HandshakeStoppedState.on(events_1.reconnect.type, function (context, event) { - return handshaking_1.HandshakingState.with(__assign(__assign({}, context), { cursor: context.cursor || event.payload.cursor })); + return handshaking_1.HandshakingState.with(__assign(__assign({}, context), { cursor: event.payload.cursor || context.cursor })); }); exports.HandshakeStoppedState.on(events_1.restore.type, function (context, event) { - var _a, _b; + var _a; return exports.HandshakeStoppedState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + region: event.payload.cursor.region || ((_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) || 0, }, }); }); diff --git a/lib/event-engine/states/handshaking.js b/lib/event-engine/states/handshaking.js index dd5833d91..788fde695 100644 --- a/lib/event-engine/states/handshaking.js +++ b/lib/event-engine/states/handshaking.js @@ -53,13 +53,13 @@ exports.HandshakingState.on(events_1.disconnect.type, function (context) { }); }); exports.HandshakingState.on(events_1.restore.type, function (context, event) { - var _a, _b; + var _a; return exports.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : (_b = (_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) !== null && _b !== void 0 ? _b : 0, + region: event.payload.cursor.region || ((_a = context === null || context === void 0 ? void 0 : context.cursor) === null || _a === void 0 ? void 0 : _a.region) || 0, }, }); }); diff --git a/lib/event-engine/states/receive_failed.js b/lib/event-engine/states/receive_failed.js index 035a80f0b..130052d36 100644 --- a/lib/event-engine/states/receive_failed.js +++ b/lib/event-engine/states/receive_failed.js @@ -13,7 +13,7 @@ exports.ReceiveFailedState.on(events_1.reconnect.type, function (context, event) groups: context.groups, cursor: { timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -29,7 +29,7 @@ exports.ReceiveFailedState.on(events_1.restore.type, function (context, event) { groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); diff --git a/lib/event-engine/states/receive_reconnecting.js b/lib/event-engine/states/receive_reconnecting.js index b7dc98dab..7f0559d5e 100644 --- a/lib/event-engine/states/receive_reconnecting.js +++ b/lib/event-engine/states/receive_reconnecting.js @@ -58,7 +58,7 @@ exports.ReceiveReconnectingState.on(events_1.restore.type, function (context, ev groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); diff --git a/lib/event-engine/states/receive_stopped.js b/lib/event-engine/states/receive_stopped.js index 09728a734..ea0eb5a13 100644 --- a/lib/event-engine/states/receive_stopped.js +++ b/lib/event-engine/states/receive_stopped.js @@ -19,7 +19,7 @@ exports.ReceiveStoppedState.on(events_1.restore.type, function (context, event) groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); @@ -30,7 +30,7 @@ exports.ReceiveStoppedState.on(events_1.reconnect.type, function (context, event groups: context.groups, cursor: { timetoken: !!event.payload.cursor.timetoken ? (_a = event.payload.cursor) === null || _a === void 0 ? void 0 : _a.timetoken : context.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); diff --git a/lib/event-engine/states/receiving.js b/lib/event-engine/states/receiving.js index e90ad8e19..122018e8e 100644 --- a/lib/event-engine/states/receiving.js +++ b/lib/event-engine/states/receiving.js @@ -49,7 +49,7 @@ exports.ReceivingState.on(events_1.restore.type, function (context, event) { groups: event.payload.groups, cursor: { timetoken: event.payload.cursor.timetoken, - region: event.payload.cursor.region ? event.payload.cursor.region : context.cursor.region, + region: event.payload.cursor.region || context.cursor.region, }, }); }); From 594b5c9e8340ccf76554f3255ffa6146aa0f5f4b Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 20:18:10 +0530 Subject: [PATCH 58/63] addressed review comments : handling cursor value from context from handshake and receiveFailed --- cucumber.js | 2 +- dist/web/pubnub.js | 9 +++++++-- dist/web/pubnub.min.js | 2 +- lib/event-engine/states/handshaking.js | 6 +++++- lib/event-engine/states/receive_failed.js | 3 ++- src/event-engine/states/handshaking.ts | 6 +++++- src/event-engine/states/receive_failed.ts | 3 ++- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/cucumber.js b/cucumber.js index ff60e6702..bc2d30986 100644 --- a/cucumber.js +++ b/cucumber.js @@ -1,6 +1,6 @@ module.exports = { default: [ - 'test/specs/features/**/*.feature', + 'test/specs/features/subscribe/event-engine/*.feature', '--require test/contract/setup.js', '--require test/contract/definitions/**/*.ts', '--require test/contract/shared/**/*.ts', diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index 32b994a64..c2c7bc49e 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -7431,10 +7431,11 @@ }, }); }); - ReceiveFailedState.on(subscriptionChange.type, function (_, event) { + ReceiveFailedState.on(subscriptionChange.type, function (context, event) { return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, + cursor: context.cursor, }); }); ReceiveFailedState.on(restore.type, function (context, event) { @@ -7636,7 +7637,11 @@ if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { return UnsubscribedState.with(undefined); } - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); }); HandshakingState.on(handshakeSuccess.type, function (context, event) { var _a, _b; diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index d9fa0ad78..cda6dd5c1 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -14,4 +14,4 @@ PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),p(o);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,h,m=l(),v=m>>5,b=31&m;if(7===v)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(b))<0&&(v<2||6=0;)S+=h,_.push(c(h));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(h);case 3:var P=[];if(h<0)for(;(h=y(v))>=0;)g(P,h);else g(P,h);return String.fromCharCode.apply(null,P);case 4:var E;if(h<0)for(E=[];!f();)E.push(e());else for(E=new Array(h),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=h,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],h=e[i+4],f=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,h,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,h,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,h,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,h,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=f[y],b=f[v],_=f[b],S=257*f[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,h[m]=S,y?(y=v^f[f[f[_^v]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^h[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,h,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&h]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[h>>>8&255]^a[255&c]^n[f++],m=r[p>>>24]^o[h>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];h=r[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&h])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^n[f++],m=(s[p>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,h=i.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,d=s.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,h=e.file,f=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,C,k,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!h)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(h),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&h.uri?(A=(T=p).POSTFILE,C=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=h?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,h=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,h=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||d||h||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:h,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Mt.on(Ct.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(kt.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(Ct.type,(function(e,t){return Ft.with(n(n({},e),{cursor:t.payload.cursor||e.cursor}))})),jt.on(gt.type,(function(e,t){var n;return jt.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?void 0:n.region)||0}})})),jt.on(kt.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(kt.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(kt.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),It.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ht({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null===(n=t.payload.cursor)||void 0===n?void 0:n.region)||(null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.region)||0}})})),Dt.on(kt.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ht({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n;return Ft.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?void 0:n.region)||0}})})),Ft.on(kt.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(Ct(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},e.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:this.delay)+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var h=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(h=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=h.message,a.file={id:h.file.id,name:h.file.name,url:this.getFileUrl({id:h.file.id,name:h.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var d;f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var h=new I({maximumSamplesCount:6e4});this._telemetryManager=h;var f=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,he),this.removeMessageAction=Q.bind(this,d,fe),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function Cn(e,t,n,r){void 0===r&&(r=On());var o,i=kn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function kn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var fr=pr,dr=hr.exports,yr=dr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Cr=Boolean.prototype.valueOf,kr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return kr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Fr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function fo(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=fo(t,f);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=fo(t,f);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,h)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=fo(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,h)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,h)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(Cr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=fo(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":h?C+"{"+ho(P,h)+"}":C+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},Co=String.prototype.replace,ko=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return Co.call(e,ko,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+h:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,h.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:Ci,post:ki,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(h.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(hn);return Bi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(f,f.exports);var d=f.exports,y=function(){return d.uuid?d.uuid():d()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=h,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],h=e[i+4],f=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,h,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,h,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,h,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,h,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=f[y],b=f[v],_=f[b],S=257*f[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,h[m]=S,y?(y=v^f[f[f[_^v]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^h[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,h,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&h]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[h>>>8&255]^a[255&c]^n[f++],m=r[p>>>24]^o[h>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];h=r[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&h])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^n[f++],m=(s[p>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,h=i.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,d=s.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,h=e.file,f=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,C,k,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!h)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(h),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&h.uri?(A=(T=p).POSTFILE,C=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=h?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,h=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,h=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||d||h||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:h,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Mt.on(Ct.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(kt.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(Ct.type,(function(e,t){return Ft.with(n(n({},e),{cursor:t.payload.cursor||e.cursor}))})),jt.on(gt.type,(function(e,t){var n;return jt.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?void 0:n.region)||0}})})),jt.on(kt.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(kt.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(kt.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),It.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ht({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null===(n=t.payload.cursor)||void 0===n?void 0:n.region)||(null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.region)||0}})})),Dt.on(kt.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ht({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n;return Ft.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?void 0:n.region)||0}})})),Ft.on(kt.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(Ct(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},e.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:this.delay)+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var h=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(h=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=h.message,a.file={id:h.file.id,name:h.file.name,url:this.getFileUrl({id:h.file.id,name:h.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var d;f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var h=new I({maximumSamplesCount:6e4});this._telemetryManager=h;var f=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,he),this.removeMessageAction=Q.bind(this,d,fe),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function Cn(e,t,n,r){void 0===r&&(r=On());var o,i=kn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function kn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var fr=pr,dr=hr.exports,yr=dr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Cr=Boolean.prototype.valueOf,kr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return kr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Fr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function fo(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=fo(t,f);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=fo(t,f);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,h)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=fo(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,h)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,h)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(Cr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=fo(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":h?C+"{"+ho(P,h)+"}":C+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},Co=String.prototype.replace,ko=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return Co.call(e,ko,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+h:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,h.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:Ci,post:ki,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(h.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(hn);return Bi})); diff --git a/lib/event-engine/states/handshaking.js b/lib/event-engine/states/handshaking.js index 788fde695..acb960681 100644 --- a/lib/event-engine/states/handshaking.js +++ b/lib/event-engine/states/handshaking.js @@ -19,7 +19,11 @@ exports.HandshakingState.on(events_1.subscriptionChange.type, function (context, if (event.payload.channels.length === 0 && event.payload.groups.length === 0) { return unsubscribed_1.UnsubscribedState.with(undefined); } - return exports.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + return exports.HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); }); exports.HandshakingState.on(events_1.handshakeSuccess.type, function (context, event) { var _a, _b; diff --git a/lib/event-engine/states/receive_failed.js b/lib/event-engine/states/receive_failed.js index 130052d36..6a880df98 100644 --- a/lib/event-engine/states/receive_failed.js +++ b/lib/event-engine/states/receive_failed.js @@ -17,10 +17,11 @@ exports.ReceiveFailedState.on(events_1.reconnect.type, function (context, event) }, }); }); -exports.ReceiveFailedState.on(events_1.subscriptionChange.type, function (_, event) { +exports.ReceiveFailedState.on(events_1.subscriptionChange.type, function (context, event) { return handshaking_1.HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, + cursor: context.cursor, }); }); exports.ReceiveFailedState.on(events_1.restore.type, function (context, event) { diff --git a/src/event-engine/states/handshaking.ts b/src/event-engine/states/handshaking.ts index 0236a190b..14ea66adc 100644 --- a/src/event-engine/states/handshaking.ts +++ b/src/event-engine/states/handshaking.ts @@ -32,7 +32,11 @@ HandshakingState.on(subscriptionChange.type, (context, event) => { return UnsubscribedState.with(undefined); } - return HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups }); + return HandshakingState.with({ + channels: event.payload.channels, + groups: event.payload.groups, + cursor: context.cursor, + }); }); HandshakingState.on(handshakeSuccess.type, (context, event) => diff --git a/src/event-engine/states/receive_failed.ts b/src/event-engine/states/receive_failed.ts index 0ca505ae4..91de8e787 100644 --- a/src/event-engine/states/receive_failed.ts +++ b/src/event-engine/states/receive_failed.ts @@ -27,10 +27,11 @@ ReceiveFailedState.on(reconnect.type, (context, event) => }), ); -ReceiveFailedState.on(subscriptionChange.type, (_, event) => +ReceiveFailedState.on(subscriptionChange.type, (context, event) => HandshakingState.with({ channels: event.payload.channels, groups: event.payload.groups, + cursor: context.cursor, }), ); From b7aaf7d99564e08bce9b052065e9ca55d2413eb5 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 20:18:55 +0530 Subject: [PATCH 59/63] revert test file changes --- cucumber.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cucumber.js b/cucumber.js index bc2d30986..1d1eddb39 100644 --- a/cucumber.js +++ b/cucumber.js @@ -1,6 +1,6 @@ module.exports = { default: [ - 'test/specs/features/subscribe/event-engine/*.feature', + 'test/specs/features/**/*.feature', '--require test/contract/setup.js', '--require test/contract/definitions/**/*.ts', '--require test/contract/shared/**/*.ts', @@ -9,4 +9,4 @@ module.exports = { // '--format @cucumber/pretty-formatter', '--publish-quiet', ].join(' '), -}; +}; \ No newline at end of file From ea443b657709defa87a4b2276022ce4ea5e6f901 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Mon, 15 Jan 2024 20:19:44 +0530 Subject: [PATCH 60/63] fix: lint --- cucumber.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cucumber.js b/cucumber.js index 1d1eddb39..ff60e6702 100644 --- a/cucumber.js +++ b/cucumber.js @@ -9,4 +9,4 @@ module.exports = { // '--format @cucumber/pretty-formatter', '--publish-quiet', ].join(' '), -}; \ No newline at end of file +}; From ed83cabce56bae0d8b48e9534b47ba98b47ae061 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 16 Jan 2024 08:21:53 +0530 Subject: [PATCH 61/63] sync package-lock --- package-lock.json | 6735 +++------------------------------------------ 1 file changed, 342 insertions(+), 6393 deletions(-) diff --git a/package-lock.json b/package-lock.json index c11314d98..0167e25f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pubnub", - "version": "7.4.4", - "lockfileVersion": 2, + "version": "7.4.5", + "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pubnub", - "version": "7.4.4", + "version": "7.4.5", "license": "SEE LICENSE IN LICENSE", "dependencies": { "agentkeepalive": "^3.5.2", @@ -917,13 +917,10 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, - "node_modules/@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "engines": { - "node": ">= 6" - } + "node_modules/@tootallnate/quickjs-emscripten": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", + "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==" }, "node_modules/@tsconfig/node10": { "version": "1.0.8", @@ -1335,6 +1332,7 @@ "version": "8.8.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "dev": true, "bin": { "acorn": "bin/acorn" }, @@ -1355,6 +1353,7 @@ "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, "engines": { "node": ">=0.4.0" } @@ -1366,14 +1365,30 @@ "dev": true }, "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", + "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==", "dependencies": { - "debug": "4" + "debug": "^4.3.4" }, "engines": { - "node": ">= 6.0.0" + "node": ">= 14" + } + }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/agentkeepalive": { @@ -1497,6 +1512,11 @@ "node": ">=0.10.0" } }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + }, "node_modules/asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -1615,6 +1635,14 @@ "node": "^4.5.0 || >= 5.9" } }, + "node_modules/basic-ftp": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.4.tgz", + "integrity": "sha512-8PzkB0arJFV4jJWSGOYR+OEic6aeKMu/osRhBULN6RY0ykby6LKhbmuQ5ublvaas5BOwboah5D87nrHyuh8PPA==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -1770,6 +1798,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true, "engines": { "node": ">= 0.8" } @@ -1778,7 +1807,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -2091,9 +2119,9 @@ } }, "node_modules/cookiejar": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", - "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" }, "node_modules/core-js-pure": { "version": "3.26.0", @@ -2110,7 +2138,8 @@ "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true }, "node_modules/create-require": { "version": "1.1.1", @@ -2358,11 +2387,11 @@ } }, "node_modules/data-uri-to-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", - "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.1.tgz", + "integrity": "sha512-MZd3VlchQkp8rdend6vrx7MmVDJzSNTBvghvKjirLkD+WTChA3KUf0jkE68Q4UyctNqI11zZO9/x2Yx+ub5Cvg==", "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/date-format": { @@ -2431,7 +2460,8 @@ "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true }, "node_modules/deepmerge": { "version": "4.2.2", @@ -2455,17 +2485,16 @@ } }, "node_modules/degenerator": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.2.tgz", - "integrity": "sha512-c0mef3SNQo56t6urUU6tdQAs+ThoD0o9B9MJ8HEt7NQcGEILCRFqQb7ZbP9JAv+QF1Ky5plydhMR/IrqWDm+TQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", + "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", "dependencies": { - "ast-types": "^0.13.2", - "escodegen": "^1.8.1", - "esprima": "^4.0.0", - "vm2": "^3.9.8" + "ast-types": "^0.13.4", + "escodegen": "^2.1.0", + "esprima": "^4.0.1" }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/delayed-stream": { @@ -2480,10 +2509,20 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "dev": true, "engines": { "node": ">= 0.6" } }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", @@ -2746,34 +2785,25 @@ } }, "node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", + "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", "dependencies": { "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" + "estraverse": "^5.2.0", + "esutils": "^2.0.2" }, "bin": { "escodegen": "bin/escodegen.js", "esgenerate": "bin/esgenerate.js" }, "engines": { - "node": ">=4.0" + "node": ">=6.0" }, "optionalDependencies": { "source-map": "~0.6.1" } }, - "node_modules/escodegen/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "engines": { - "node": ">=4.0" - } - }, "node_modules/eslint": { "version": "8.37.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", @@ -3140,7 +3170,6 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, "engines": { "node": ">=4.0" } @@ -3277,7 +3306,8 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true }, "node_modules/fast-safe-stringify": { "version": "2.1.1", @@ -3329,14 +3359,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-uri-to-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", - "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==", - "engines": { - "node": ">= 6" - } - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -3470,14 +3492,33 @@ } }, "node_modules/formidable": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", - "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==", - "deprecated": "Please upgrade to latest, formidable@v2 or formidable@v3! Check these notes: https://bit.ly/2ZEqIau", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-2.1.2.tgz", + "integrity": "sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==", + "dependencies": { + "dezalgo": "^1.0.4", + "hexoid": "^1.0.0", + "once": "^1.4.0", + "qs": "^6.11.0" + }, "funding": { "url": "https://ko-fi.com/tunnckoCore/commissions" } }, + "node_modules/formidable/node_modules/qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/fs-extra": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", @@ -3509,44 +3550,10 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", - "dependencies": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/ftp/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "node_modules/ftp/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/ftp/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "node_modules/functional-red-black-tree": { "version": "1.0.1", @@ -3576,7 +3583,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -3587,19 +3593,33 @@ } }, "node_modules/get-uri": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", - "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.2.tgz", + "integrity": "sha512-5KLucCJobh8vBY1K07EFV4+cPZH3mrV9YeAruUseCQKHB58SGjjT2l9/eA9LD082IiuMjSlFJEcdJ27TXvbZNw==", "dependencies": { - "@tootallnate/once": "1", - "data-uri-to-buffer": "3", - "debug": "4", - "file-uri-to-path": "2", - "fs-extra": "^8.1.0", - "ftp": "^0.3.10" + "basic-ftp": "^5.0.2", + "data-uri-to-buffer": "^6.0.0", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/get-uri/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/get-uri/node_modules/fs-extra": { @@ -3618,7 +3638,7 @@ "node_modules/get-uri/node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -3757,7 +3777,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -3799,7 +3818,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true, "engines": { "node": ">= 0.4" }, @@ -3853,10 +3871,19 @@ "he": "bin/he" } }, + "node_modules/hexoid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", + "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==", + "engines": { + "node": ">=8" + } + }, "node_modules/http-errors": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "dev": true, "dependencies": { "depd": "~1.1.2", "inherits": "2.0.4", @@ -3883,16 +3910,31 @@ } }, "node_modules/http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz", + "integrity": "sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==", "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" + "agent-base": "^7.1.0", + "debug": "^4.3.4" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/http-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/http-signature": { @@ -3911,15 +3953,15 @@ } }, "node_modules/https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.2.tgz", + "integrity": "sha512-NmLNjm6ucYwtcUmL7JQC1ZQ57LmHP4lT15FQ8D61nak1rO6DH+fz5qNK2Ap5UN4ZapYICE3/0KodcLYSPsPbaA==", "dependencies": { - "agent-base": "6", + "agent-base": "^7.0.2", "debug": "4" }, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/humanize-ms": { @@ -3934,6 +3976,7 @@ "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -4022,12 +4065,13 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true }, "node_modules/ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", + "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==" }, "node_modules/is-arguments": { "version": "1.1.1", @@ -4785,18 +4829,6 @@ "seed-random": "~2.2.0" } }, - "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/lil-uuid": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", @@ -4947,11 +4979,11 @@ } }, "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dependencies": { - "yallist": "^3.0.2" + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "engines": { + "node": ">=12" } }, "node_modules/magic-string": { @@ -5484,6 +5516,14 @@ "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/object-is": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", @@ -5525,27 +5565,10 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "dependencies": { "wrappy": "1" } }, - "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -5577,35 +5600,50 @@ } }, "node_modules/pac-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", - "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.1.tgz", + "integrity": "sha512-ASV8yU4LLKBAjqIPMbrgtaKIvxQri/yh2OpI+S6hVa9JRkUI3Y3NPFbfngDtY7oFtSMD3w31Xns89mDa3Feo5A==", "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4", - "get-uri": "3", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "5", - "pac-resolver": "^5.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "5" + "@tootallnate/quickjs-emscripten": "^0.23.0", + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "get-uri": "^6.0.1", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.2", + "pac-resolver": "^7.0.0", + "socks-proxy-agent": "^8.0.2" }, "engines": { - "node": ">= 8" + "node": ">= 14" + } + }, + "node_modules/pac-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/pac-resolver": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.0.tgz", - "integrity": "sha512-H+/A6KitiHNNW+bxBKREk2MCGSxljfqRX76NjummWEYIat7ldVXRU3dhRIE3iXZ0nvGBk6smv3nntxKkzRL8NA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", + "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", "dependencies": { - "degenerator": "^3.0.1", - "ip": "^1.1.5", - "netmask": "^2.0.1" + "degenerator": "^5.0.0", + "ip": "^1.1.8", + "netmask": "^2.0.2" }, "engines": { - "node": ">= 8" + "node": ">= 14" } }, "node_modules/pad-right": { @@ -5795,14 +5833,6 @@ "node": ">=0.10.0" } }, - "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/prettier": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", @@ -5884,21 +5914,37 @@ ] }, "node_modules/proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", - "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.3.1.tgz", + "integrity": "sha512-Rb5RVBy1iyqOtNl15Cw/llpeLH8bsb37gM1FUfKQ+Wck6xHlbAhWGUFiTRHtkjqGTA5pSHz6+0hrPW/oECihPQ==", "dependencies": { - "agent-base": "^6.0.0", - "debug": "4", - "http-proxy-agent": "^4.0.0", - "https-proxy-agent": "^5.0.0", - "lru-cache": "^5.1.1", - "pac-proxy-agent": "^5.0.0", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^5.0.0" + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.2", + "lru-cache": "^7.14.1", + "pac-proxy-agent": "^7.0.1", + "proxy-from-env": "^1.1.0", + "socks-proxy-agent": "^8.0.2" }, "engines": { - "node": ">= 8" + "node": ">= 14" + } + }, + "node_modules/proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/proxy-from-env": { @@ -5934,6 +5980,7 @@ "version": "6.9.7", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "dev": true, "engines": { "node": ">=0.6" }, @@ -5989,6 +6036,7 @@ "version": "2.4.3", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", + "dev": true, "dependencies": { "bytes": "3.1.2", "http-errors": "1.8.1", @@ -6321,12 +6369,14 @@ "node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true }, "node_modules/seed-random": { "version": "2.2.0", @@ -6405,7 +6455,8 @@ "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true }, "node_modules/shebang-command": { "version": "2.0.0", @@ -6428,6 +6479,19 @@ "node": ">=8" } }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/sinon": { "version": "7.5.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", @@ -6595,11 +6659,11 @@ } }, "node_modules/socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", + "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "dependencies": { - "ip": "^1.1.5", + "ip": "^2.0.0", "smart-buffer": "^4.2.0" }, "engines": { @@ -6608,18 +6672,39 @@ } }, "node_modules/socks-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", - "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.2.tgz", + "integrity": "sha512-8zuqoLv1aP/66PHF5TqwJ7Czm3Yv32urJQHrVyhD7mmA6d61Zv8cIXQYPTWwmg6qlupnPvs/QKDmfa4P/qct2g==", "dependencies": { - "agent-base": "^6.0.2", - "debug": "4", - "socks": "^2.3.3" + "agent-base": "^7.0.2", + "debug": "^4.3.4", + "socks": "^2.7.1" }, "engines": { - "node": ">= 6" + "node": ">= 14" + } + }, + "node_modules/socks-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, + "node_modules/socks/node_modules/ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -6752,6 +6837,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true, "engines": { "node": ">= 0.6" } @@ -6809,6 +6895,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, "dependencies": { "safe-buffer": "~5.1.0" } @@ -6877,46 +6964,45 @@ } }, "node_modules/superagent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-6.1.0.tgz", - "integrity": "sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==", - "deprecated": "Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at .", + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-8.1.2.tgz", + "integrity": "sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==", "dependencies": { "component-emitter": "^1.3.0", - "cookiejar": "^2.1.2", - "debug": "^4.1.1", - "fast-safe-stringify": "^2.0.7", - "form-data": "^3.0.0", - "formidable": "^1.2.2", + "cookiejar": "^2.1.4", + "debug": "^4.3.4", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.0", + "formidable": "^2.1.2", "methods": "^1.1.2", - "mime": "^2.4.6", - "qs": "^6.9.4", - "readable-stream": "^3.6.0", - "semver": "^7.3.2" + "mime": "2.6.0", + "qs": "^6.11.0", + "semver": "^7.3.8" }, "engines": { - "node": ">= 7.0.0" + "node": ">=6.4.0 <13 || >=14" } }, - "node_modules/superagent-proxy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/superagent-proxy/-/superagent-proxy-3.0.0.tgz", - "integrity": "sha512-wAlRInOeDFyd9pyonrkJspdRAxdLrcsZ6aSnS+8+nu4x1aXbz6FWSTT9M6Ibze+eG60szlL7JA8wEIV7bPWuyQ==", + "node_modules/superagent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { - "debug": "^4.3.2", - "proxy-agent": "^5.0.0" + "ms": "2.1.2" }, "engines": { - "node": ">=6" + "node": ">=6.0" }, - "peerDependencies": { - "superagent": ">= 0.15.4 || 1 || 2 || 3" + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/superagent/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -6926,17 +7012,18 @@ "node": ">= 6" } }, - "node_modules/superagent/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "node_modules/superagent/node_modules/qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "side-channel": "^1.0.4" }, "engines": { - "node": ">= 6" + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/supports-color": { @@ -7091,6 +7178,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, "engines": { "node": ">=0.6" } @@ -7303,17 +7391,6 @@ "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", "dev": true }, - "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -7394,6 +7471,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "dev": true, "engines": { "node": ">= 0.8" } @@ -7432,7 +7510,8 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true }, "node_modules/utils-merge": { "version": "1.0.1", @@ -7479,21 +7558,6 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "node_modules/vm2": { - "version": "3.9.8", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.8.tgz", - "integrity": "sha512-/1PYg/BwdKzMPo8maOZ0heT7DLI0DAFTm7YQaz/Lim9oIaFZsJs3EdtalvXuBfZwczNwsYhju75NW4d6E+4q+w==", - "dependencies": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - }, - "bin": { - "vm2": "bin/vm2" - }, - "engines": { - "node": ">=6.0" - } - }, "node_modules/void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", @@ -7541,6 +7605,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -7601,8 +7666,7 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "node_modules/ws": { "version": "7.4.6", @@ -7634,25 +7698,12 @@ "node": ">=0.4.0" } }, - "node_modules/xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=", - "engines": { - "node": "*" - } - }, "node_modules/y18n": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", "dev": true }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" - }, "node_modules/yargs": { "version": "15.4.1", "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", @@ -7834,6107 +7885,5 @@ "url": "https://github.com/sponsors/sindresorhus" } } - }, - "dependencies": { - "@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, - "requires": { - "@babel/highlight": "^7.16.7" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true - }, - "@babel/highlight": { - "version": "7.16.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.10.tgz", - "integrity": "sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.16.7", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } - }, - "@babel/runtime-corejs3": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.0.tgz", - "integrity": "sha512-v1JH7PeAAGBEyTQM9TqojVl+b20zXtesFKCJHu50xMxZKD1fX0TKaKHPsZfFkXfs7D1M9M6Eeqg1FkJ3a0x2dA==", - "dev": true, - "peer": true, - "requires": { - "core-js-pure": "^3.25.1", - "regenerator-runtime": "^0.13.10" - } - }, - "@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", - "dev": true, - "optional": true - }, - "@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "requires": { - "@jridgewell/trace-mapping": "0.3.9" - } - }, - "@cucumber/create-meta": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/create-meta/-/create-meta-5.0.0.tgz", - "integrity": "sha512-Z5kMZkUff00S3/KSnKzB/KOm2UIxMXY1xXmj2dQMlD49lV6v/W8EEvgDMNtQotQNSOQU5bDupmWQpk+o16tXIw==", - "dev": true, - "requires": { - "@cucumber/messages": "^16.0.0" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } - } - }, - "@cucumber/cucumber": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/@cucumber/cucumber/-/cucumber-7.3.2.tgz", - "integrity": "sha512-qqptM9w+UqXEYBAkrIGpIVPXDWv+zp0LrS89LiwHZwBp0cJg00su/iPMZ4j8TvCJiKfAwJXsAI1yjrd1POtU+w==", - "dev": true, - "requires": { - "@cucumber/create-meta": "^5.0.0", - "@cucumber/cucumber-expressions": "^12.1.1", - "@cucumber/gherkin": "^19.0.3", - "@cucumber/gherkin-streams": "^2.0.2", - "@cucumber/html-formatter": "^15.0.2", - "@cucumber/messages": "^16.0.1", - "@cucumber/tag-expressions": "^3.0.1", - "assertion-error-formatter": "^3.0.0", - "bluebird": "^3.7.2", - "capital-case": "^1.0.4", - "cli-table3": "0.6.1", - "colors": "1.4.0", - "commander": "^7.0.0", - "create-require": "^1.1.1", - "duration": "^0.2.2", - "durations": "^3.4.2", - "figures": "^3.2.0", - "glob": "^7.1.6", - "indent-string": "^4.0.0", - "is-generator": "^1.0.3", - "is-stream": "^2.0.0", - "knuth-shuffle-seeded": "^1.0.6", - "lodash": "^4.17.21", - "mz": "^2.7.0", - "progress": "^2.0.3", - "resolve": "^1.19.0", - "resolve-pkg": "^2.0.0", - "stack-chain": "^2.0.0", - "stacktrace-js": "^2.0.2", - "string-argv": "^0.3.1", - "tmp": "^0.2.1", - "util-arity": "^1.1.0", - "verror": "^1.10.0" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "cli-table3": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.1.tgz", - "integrity": "sha512-w0q/enDHhPLq44ovMGdQeeDLvwxwavsJX7oQGYt/LrBlYsyaxyDnp6z3QzFut/6kLLKnlcUVJLrpB7KBfgG/RA==", - "dev": true, - "requires": { - "colors": "1.4.0", - "string-width": "^4.2.0" - } - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } - } - }, - "@cucumber/cucumber-expressions": { - "version": "12.1.3", - "resolved": "https://registry.npmjs.org/@cucumber/cucumber-expressions/-/cucumber-expressions-12.1.3.tgz", - "integrity": "sha512-LB8MAzE4F/t2KIgsDEz4gZH0xSI4aG0/LmYUPyISPPjUS1pI/yGWWyeX2WsiUQxpSs765WcNIq5Bggt7gGGO3Q==", - "dev": true, - "requires": { - "regexp-match-indices": "1.0.2" - } - }, - "@cucumber/gherkin": { - "version": "19.0.3", - "resolved": "https://registry.npmjs.org/@cucumber/gherkin/-/gherkin-19.0.3.tgz", - "integrity": "sha512-gWdMm8mfRk3P+VugJWvNALaQV5QnT+5RkqWy3tO+4NsMSQZPo5p4V4vXwriQZ/sZR1Wni5TDRztuRsKLgZ3XHA==", - "dev": true, - "requires": { - "@cucumber/message-streams": "^2.0.0", - "@cucumber/messages": "^16.0.1" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } - } - }, - "@cucumber/gherkin-streams": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@cucumber/gherkin-streams/-/gherkin-streams-2.0.2.tgz", - "integrity": "sha512-cKmXOBz4OwGlrHMBCc4qCC3KzLaqcEZ11nWWskIbv6jyfvlIRuM2OgEF6VLcNVewczifW1p6DrDj0OO+BeXocA==", - "dev": true, - "requires": { - "@cucumber/gherkin": "^19.0.1", - "@cucumber/message-streams": "^2.0.0", - "@cucumber/messages": "^16.0.0", - "commander": "7.2.0", - "source-map-support": "0.5.19" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } - } - }, - "@cucumber/html-formatter": { - "version": "15.0.2", - "resolved": "https://registry.npmjs.org/@cucumber/html-formatter/-/html-formatter-15.0.2.tgz", - "integrity": "sha512-j+YGY4ytj78G/v1gZo53D+vuKXlTg/oxNwSCCGvRQo75+AqYDJSkm/vexXJQ5lY1rXAvlbZ9KI6jhg6LDs0YdQ==", - "dev": true, - "requires": { - "@cucumber/messages": "^16.0.1", - "commander": "7.2.0", - "source-map-support": "0.5.19" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "source-map-support": { - "version": "0.5.19", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", - "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } - } - }, - "@cucumber/message-streams": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@cucumber/message-streams/-/message-streams-2.1.0.tgz", - "integrity": "sha512-Yh3mw3qv6QL9NI/ihkZF8V9MX2GbnR6oktv34kC3uAbrQy9d/b2SZ3HNjG3J9JQqpV4B7Om3SPElJYIeo66TrA==", - "dev": true, - "requires": { - "@cucumber/messages": "^16.0.1" - }, - "dependencies": { - "@cucumber/messages": { - "version": "16.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-16.0.1.tgz", - "integrity": "sha512-80JcaAfQragFqR1rMhRwiqWL9HcR6Z4LDD2mfF0Lxg/lFkCNvmWa9Jl10NUNfFXYD555NKPzP/8xFo55abw8TQ==", - "dev": true, - "requires": { - "@types/uuid": "8.3.0", - "class-transformer": "0.4.0", - "reflect-metadata": "0.1.13", - "uuid": "8.3.2" - } - }, - "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", - "dev": true - }, - "class-transformer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.4.0.tgz", - "integrity": "sha512-ETWD/H2TbWbKEi7m9N4Km5+cw1hNcqJSxlSYhsLsNjQzWWiZIYA1zafxpK9PwVfaZ6AqR5rrjPVUBGESm5tQUA==", - "dev": true - }, - "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true - } - } - }, - "@cucumber/messages": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/messages/-/messages-21.0.1.tgz", - "integrity": "sha512-pGR7iURM4SF9Qp1IIpNiVQ77J9kfxMkPOEbyy+zRmGABnWWCsqMpJdfHeh9Mb3VskemVw85++e15JT0PYdcR3g==", - "dev": true, - "peer": true, - "requires": { - "@types/uuid": "8.3.4", - "class-transformer": "0.5.1", - "reflect-metadata": "0.1.13", - "uuid": "9.0.0" - } - }, - "@cucumber/pretty-formatter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@cucumber/pretty-formatter/-/pretty-formatter-1.0.0.tgz", - "integrity": "sha512-wcnIMN94HyaHGsfq72dgCvr1d8q6VGH4Y6Gl5weJ2TNZw1qn2UY85Iki4c9VdaLUONYnyYH3+178YB+9RFe/Hw==", - "dev": true, - "requires": { - "ansi-styles": "^5.0.0", - "cli-table3": "^0.6.0", - "figures": "^3.2.0", - "ts-dedent": "^2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true - } - } - }, - "@cucumber/tag-expressions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@cucumber/tag-expressions/-/tag-expressions-3.0.1.tgz", - "integrity": "sha512-OGCXaJ1BQXmQ5b9pw+JYsBGumK2/LPZiLmbj1o1JFVeSNs2PY8WPQFSyXrskhrHz5Nd/6lYg7lvGMtFHOncC4w==", - "dev": true - }, - "@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^3.3.0" - } - }, - "@eslint-community/regexpp": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", - "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", - "dev": true - }, - "@eslint/eslintrc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", - "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.5.1", - "globals": "^13.19.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "dependencies": { - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - } - } - }, - "@eslint/js": { - "version": "8.37.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.37.0.tgz", - "integrity": "sha512-x5vzdtOOGgFVDCUs81QRB2+liax8rFg3+7hqM+QhBG0/G3F1ZsoYl97UrqgHgQ9KKT7G6c4V+aTUCgu/n22v1A==", - "dev": true - }, - "@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", - "dev": true, - "requires": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", - "minimatch": "^3.0.5" - } - }, - "@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true - }, - "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", - "dev": true - }, - "@jest/types": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.5.1.tgz", - "integrity": "sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==", - "dev": true, - "requires": { - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^16.0.0", - "chalk": "^4.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "@jridgewell/resolve-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", - "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", - "dev": true - }, - "@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", - "dev": true - }, - "@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, - "@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - } - }, - "@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true - }, - "@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "requires": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - } - }, - "@rollup/plugin-commonjs": { - "version": "21.0.2", - "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-21.0.2.tgz", - "integrity": "sha512-d/OmjaLVO4j/aQX69bwpWPpbvI3TJkQuxoAk7BH8ew1PyoMBLTOuvJTjzG8oEoW7drIIqB0KCJtfFLu/2GClWg==", - "dev": true, - "requires": { - "@rollup/pluginutils": "^3.1.0", - "commondir": "^1.0.1", - "estree-walker": "^2.0.1", - "glob": "^7.1.6", - "is-reference": "^1.2.1", - "magic-string": "^0.25.7", - "resolve": "^1.17.0" - } - }, - "@rollup/plugin-json": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-4.1.0.tgz", - "integrity": "sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==", - "dev": true, - "requires": { - "@rollup/pluginutils": "^3.0.8" - } - }, - "@rollup/plugin-node-resolve": { - "version": "13.1.3", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.1.3.tgz", - "integrity": "sha512-BdxNk+LtmElRo5d06MGY4zoepyrXX1tkzX2hrnPEZ53k78GuOMWLqmJDGIIOPwVRIFZrLQOo+Yr6KtCuLIA0AQ==", - "dev": true, - "requires": { - "@rollup/pluginutils": "^3.1.0", - "@types/resolve": "1.17.1", - "builtin-modules": "^3.1.0", - "deepmerge": "^4.2.2", - "is-module": "^1.0.0", - "resolve": "^1.19.0" - } - }, - "@rollup/plugin-typescript": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.3.1.tgz", - "integrity": "sha512-84rExe3ICUBXzqNX48WZV2Jp3OddjTMX97O2Py6D1KJaGSwWp0mDHXj+bCGNJqWHIEKDIT2U0sDjhP4czKi6cA==", - "dev": true, - "requires": { - "@rollup/pluginutils": "^3.1.0", - "resolve": "^1.17.0" - } - }, - "@rollup/pluginutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", - "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", - "dev": true, - "requires": { - "@types/estree": "0.0.39", - "estree-walker": "^1.0.1", - "picomatch": "^2.2.2" - }, - "dependencies": { - "estree-walker": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", - "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", - "dev": true - } - } - }, - "@sinonjs/commons": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", - "integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==", - "dev": true, - "requires": { - "type-detect": "4.0.8" - } - }, - "@sinonjs/formatio": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.2.2.tgz", - "integrity": "sha512-B8SEsgd8gArBLMD6zpRw3juQ2FVSsmdd7qlevyDqzS9WTCtvF55/gAL+h6gue8ZvPYcdiPdvueM/qm//9XzyTQ==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1", - "@sinonjs/samsam": "^3.1.0" - } - }, - "@sinonjs/samsam": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.3.tgz", - "integrity": "sha512-bKCMKZvWIjYD0BLGnNrxVuw4dkWCYsLqFOUWw8VgKF/+5Y+mE7LfHWPIYoDXowH+3a9LsWDMo0uAP8YDosPvHQ==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.3.0", - "array-from": "^2.1.1", - "lodash": "^4.17.15" - } - }, - "@sinonjs/text-encoding": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", - "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", - "dev": true - }, - "@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==" - }, - "@tsconfig/node10": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz", - "integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==", - "dev": true - }, - "@tsconfig/node12": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz", - "integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==", - "dev": true - }, - "@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==", - "dev": true - }, - "@tsconfig/node16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", - "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", - "dev": true - }, - "@types/chai": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.3.tgz", - "integrity": "sha512-hC7OMnszpxhZPduX+m+nrx+uFoLkWOMiR4oa/AZF3MuSETYTZmFfJAHqZEM8MVlvfG7BEUcgvtwoCTxBp6hm3g==", - "dev": true - }, - "@types/cucumber": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@types/cucumber/-/cucumber-7.0.0.tgz", - "integrity": "sha512-cr5NN8/jmbw3vDKTQfGW0cSzDtkvxixu9bUD6po9U6OEF04XLuukTDldFG34ccDscLkA8bYnZ7VjxP79cIC7tg==", - "dev": true, - "requires": { - "@cucumber/cucumber": "*" - } - }, - "@types/estree": { - "version": "0.0.39", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", - "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", - "dev": true - }, - "@types/expect": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@types/expect/-/expect-24.3.0.tgz", - "integrity": "sha512-aq5Z+YFBz5o2b6Sp1jigx5nsmoZMK5Ceurjwy6PZmRv7dEi1jLtkARfvB1ME+OXJUG+7TZUDcv3WoCr/aor6dQ==", - "dev": true, - "requires": { - "expect": "*" - } - }, - "@types/istanbul-lib-coverage": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", - "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", - "dev": true - }, - "@types/istanbul-lib-report": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", - "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", - "dev": true, - "requires": { - "@types/istanbul-lib-coverage": "*" - } - }, - "@types/istanbul-reports": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", - "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", - "dev": true, - "requires": { - "@types/istanbul-lib-report": "*" - } - }, - "@types/json-schema": { - "version": "7.0.9", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", - "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", - "dev": true - }, - "@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", - "dev": true, - "optional": true - }, - "@types/mocha": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", - "integrity": "sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg==", - "dev": true - }, - "@types/nock": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/@types/nock/-/nock-9.3.1.tgz", - "integrity": "sha512-eOVHXS5RnWOjTVhu3deCM/ruy9E6JCgeix2g7wpFiekQh3AaEAK1cz43tZDukKmtSmQnwvSySq7ubijCA32I7Q==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, - "@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", - "dev": true - }, - "@types/node-fetch": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", - "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", - "dev": true, - "requires": { - "@types/node": "*", - "form-data": "^3.0.0" - }, - "dependencies": { - "form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - } - } - }, - "@types/pubnub": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@types/pubnub/-/pubnub-7.2.0.tgz", - "integrity": "sha512-Ui58Xsn8/4Ty1hFW0t91ED6FKezzipjO+GEJviOdJdqp817+I5/WMfo5zBsDfjbZQWMqcdrktMauKpUqiIF1wA==", - "dev": true - }, - "@types/resolve": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", - "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, - "@types/stack-utils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", - "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", - "dev": true - }, - "@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", - "dev": true, - "peer": true - }, - "@types/yargs": { - "version": "16.0.4", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", - "integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==", - "dev": true, - "requires": { - "@types/yargs-parser": "*" - } - }, - "@types/yargs-parser": { - "version": "20.2.1", - "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.1.tgz", - "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==", - "dev": true - }, - "@typescript-eslint/eslint-plugin": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.12.1.tgz", - "integrity": "sha512-M499lqa8rnNK7mUv74lSFFttuUsubIRdAbHcVaP93oFcKkEmHmLqy2n7jM9C8DVmFMYK61ExrZU6dLYhQZmUpw==", - "dev": true, - "requires": { - "@typescript-eslint/scope-manager": "5.12.1", - "@typescript-eslint/type-utils": "5.12.1", - "@typescript-eslint/utils": "5.12.1", - "debug": "^4.3.2", - "functional-red-black-tree": "^1.0.1", - "ignore": "^5.1.8", - "regexpp": "^3.2.0", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/parser": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.12.1.tgz", - "integrity": "sha512-6LuVUbe7oSdHxUWoX/m40Ni8gsZMKCi31rlawBHt7VtW15iHzjbpj2WLiToG2758KjtCCiLRKZqfrOdl3cNKuw==", - "dev": true, - "requires": { - "@typescript-eslint/scope-manager": "5.12.1", - "@typescript-eslint/types": "5.12.1", - "@typescript-eslint/typescript-estree": "5.12.1", - "debug": "^4.3.2" - } - }, - "@typescript-eslint/scope-manager": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.12.1.tgz", - "integrity": "sha512-J0Wrh5xS6XNkd4TkOosxdpObzlYfXjAFIm9QxYLCPOcHVv1FyyFCPom66uIh8uBr0sZCrtS+n19tzufhwab8ZQ==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.12.1", - "@typescript-eslint/visitor-keys": "5.12.1" - } - }, - "@typescript-eslint/type-utils": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.12.1.tgz", - "integrity": "sha512-Gh8feEhsNLeCz6aYqynh61Vsdy+tiNNkQtc+bN3IvQvRqHkXGUhYkUi+ePKzP0Mb42se7FDb+y2SypTbpbR/Sg==", - "dev": true, - "requires": { - "@typescript-eslint/utils": "5.12.1", - "debug": "^4.3.2", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/types": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.12.1.tgz", - "integrity": "sha512-hfcbq4qVOHV1YRdhkDldhV9NpmmAu2vp6wuFODL71Y0Ixak+FLeEU4rnPxgmZMnGreGEghlEucs9UZn5KOfHJA==", - "dev": true - }, - "@typescript-eslint/typescript-estree": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.12.1.tgz", - "integrity": "sha512-ahOdkIY9Mgbza7L9sIi205Pe1inCkZWAHE1TV1bpxlU4RZNPtXaDZfiiFWcL9jdxvW1hDYZJXrFm+vlMkXRbBw==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.12.1", - "@typescript-eslint/visitor-keys": "5.12.1", - "debug": "^4.3.2", - "globby": "^11.0.4", - "is-glob": "^4.0.3", - "semver": "^7.3.5", - "tsutils": "^3.21.0" - } - }, - "@typescript-eslint/utils": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.12.1.tgz", - "integrity": "sha512-Qq9FIuU0EVEsi8fS6pG+uurbhNTtoYr4fq8tKjBupsK5Bgbk2I32UGm0Sh+WOyjOPgo/5URbxxSNV6HYsxV4MQ==", - "dev": true, - "requires": { - "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.12.1", - "@typescript-eslint/types": "5.12.1", - "@typescript-eslint/typescript-estree": "5.12.1", - "eslint-scope": "^5.1.1", - "eslint-utils": "^3.0.0" - }, - "dependencies": { - "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - } - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - } - } - }, - "@typescript-eslint/visitor-keys": { - "version": "5.12.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.12.1.tgz", - "integrity": "sha512-l1KSLfupuwrXx6wc0AuOmC7Ko5g14ZOQ86wJJqRbdLbXLK02pK/DPiDDqCc7BqqiiA04/eAA6ayL0bgOrAkH7A==", - "dev": true, - "requires": { - "@typescript-eslint/types": "5.12.1", - "eslint-visitor-keys": "^3.0.0" - } - }, - "@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, - "accepts": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", - "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", - "dev": true, - "requires": { - "mime-types": "~2.1.34", - "negotiator": "0.6.3" - } - }, - "acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==" - }, - "acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} - }, - "acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==" - }, - "after": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", - "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", - "dev": true - }, - "agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "requires": { - "debug": "4" - } - }, - "agentkeepalive": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-3.5.2.tgz", - "integrity": "sha512-e0L/HNe6qkQ7H19kTlRRqUibEAwDK5AFk6y3PtMsuut2VAH6+Q4xZml1tNDJD7kSAyqmbG/K08K5WEJYtUrSlQ==", - "requires": { - "humanize-ms": "^1.2.1" - } - }, - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", - "dev": true - }, - "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "array-from": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", - "dev": true - }, - "array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true - }, - "arraybuffer.slice": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", - "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==", - "dev": true - }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "asn1": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", - "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", - "dev": true, - "requires": { - "safer-buffer": "~2.1.0" - } - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, - "assertion-error-formatter": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/assertion-error-formatter/-/assertion-error-formatter-3.0.0.tgz", - "integrity": "sha512-6YyAVLrEze0kQ7CmJfUgrLHb+Y7XghmL2Ie7ijVa2Y9ynP3LV+VDiwFk62Dn0qtqbmY0BT0ss6p1xxpiF2PYbQ==", - "dev": true, - "requires": { - "diff": "^4.0.1", - "pad-right": "^0.2.2", - "repeat-string": "^1.6.1" - } - }, - "ast-types": { - "version": "0.13.4", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", - "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", - "requires": { - "tslib": "^2.0.1" - } - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true - }, - "aws4": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", - "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", - "dev": true - }, - "backo2": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", - "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=", - "dev": true - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "base64-arraybuffer": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz", - "integrity": "sha1-mBjHngWbE1X5fgQooBfIOOkLqBI=", - "dev": true - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" - }, - "base64id": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", - "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", - "dev": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "becke-ch--regex--s0-0-v1--base--pl--lib": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", - "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==", - "dev": true, - "peer": true - }, - "binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true - }, - "blob": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", - "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==", - "dev": true - }, - "bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", - "dev": true - }, - "body-parser": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz", - "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==", - "dev": true, - "requires": { - "bytes": "3.1.2", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.8.1", - "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.9.7", - "raw-body": "2.4.3", - "type-is": "~1.6.18" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "requires": { - "fill-range": "^7.0.1" - } - }, - "browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true - }, - "buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true - }, - "builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", - "dev": true - }, - "bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" - }, - "call-bind": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", - "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - } - }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true - }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true - }, - "capital-case": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz", - "integrity": "sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==", - "dev": true, - "requires": { - "no-case": "^3.0.4", - "tslib": "^2.0.3", - "upper-case-first": "^2.0.2" - } - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, - "cbor-js": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/cbor-js/-/cbor-js-0.1.0.tgz", - "integrity": "sha1-yAzmEg84fo+qdDcN/aIdlluPx/k=" - }, - "cbor-sync": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cbor-sync/-/cbor-sync-1.0.4.tgz", - "integrity": "sha512-GWlXN4wiz0vdWWXBU71Dvc1q3aBo0HytqwAZnXF1wOwjqNnDWA1vZ1gDMFLlqohak31VQzmhiYfiCX5QSSfagA==" - }, - "chai": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", - "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - } - }, - "chai-as-promised": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz", - "integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==", - "dev": true, - "requires": { - "check-error": "^1.0.2" - } - }, - "chai-nock": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/chai-nock/-/chai-nock-1.3.0.tgz", - "integrity": "sha512-O3j1bW3ACoUu/sLGYSoX50c1p8dbTkCjw3/dereqzl9BL2XsQAUVC18sJpg3hVwpCk71rjWGumCmHy87t5W+Pg==", - "dev": true, - "requires": { - "chai": "^4.2.0", - "deep-equal": "^1.0.1" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, - "chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "class-transformer": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", - "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", - "dev": true, - "peer": true - }, - "cli-table3": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.3.tgz", - "integrity": "sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg==", - "dev": true, - "requires": { - "@colors/colors": "1.5.0", - "string-width": "^4.2.0" - } - }, - "cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "colors": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", - "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", - "dev": true - }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "commander": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", - "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", - "dev": true - }, - "commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", - "dev": true - }, - "component-bind": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", - "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", - "dev": true - }, - "component-emitter": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" - }, - "component-inherit": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", - "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, - "connect": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", - "integrity": "sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==", - "dev": true, - "requires": { - "debug": "2.6.9", - "finalhandler": "1.1.2", - "parseurl": "~1.3.3", - "utils-merge": "1.0.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", - "dev": true - }, - "cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", - "dev": true - }, - "cookiejar": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", - "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" - }, - "core-js-pure": { - "version": "3.26.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", - "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", - "dev": true, - "peer": true - }, - "core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" - }, - "create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "dependencies": { - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } - } - }, - "cucumber": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.7.tgz", - "integrity": "sha512-pN3AgWxHx8rOi+wOlqjASNETOjf3TgeyqhMNLQam7nSTXgQzju1oAmXkleRQRcXvpVvejcDHiZBLFSfBkqbYpA==", - "dev": true, - "peer": true, - "requires": { - "assertion-error-formatter": "^3.0.0", - "bluebird": "^3.4.1", - "cli-table3": "^0.5.1", - "colors": "^1.1.2", - "commander": "^3.0.1", - "cucumber-expressions": "^8.1.0", - "cucumber-tag-expressions": "^2.0.2", - "duration": "^0.2.1", - "escape-string-regexp": "^2.0.0", - "figures": "^3.0.0", - "gherkin": "5.0.0", - "glob": "^7.1.3", - "indent-string": "^4.0.0", - "is-generator": "^1.0.2", - "is-stream": "^2.0.0", - "knuth-shuffle-seeded": "^1.0.6", - "lodash": "^4.17.14", - "mz": "^2.4.0", - "progress": "^2.0.0", - "resolve": "^1.3.3", - "serialize-error": "^4.1.0", - "stack-chain": "^2.0.0", - "stacktrace-js": "^2.0.0", - "string-argv": "^0.3.0", - "title-case": "^2.1.1", - "util-arity": "^1.0.2", - "verror": "^1.9.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true, - "peer": true - }, - "cli-table3": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", - "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", - "dev": true, - "peer": true, - "requires": { - "colors": "^1.1.2", - "object-assign": "^4.1.0", - "string-width": "^2.1.1" - } - }, - "commander": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.2.tgz", - "integrity": "sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==", - "dev": true, - "peer": true - }, - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true, - "peer": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", - "dev": true, - "peer": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "peer": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", - "dev": true, - "peer": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, - "cucumber-expressions": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/cucumber-expressions/-/cucumber-expressions-8.3.0.tgz", - "integrity": "sha512-cP2ya0EiorwXBC7Ll7Cj7NELYbasNv9Ty42L4u7sso9KruWemWG1ZiTq4PMqir3SNDSrbykoqI5wZgMbLEDjLQ==", - "dev": true, - "peer": true, - "requires": { - "becke-ch--regex--s0-0-v1--base--pl--lib": "^1.4.0", - "xregexp": "^4.2.4" - }, - "dependencies": { - "xregexp": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.4.1.tgz", - "integrity": "sha512-2u9HwfadaJaY9zHtRRnH6BY6CQVNQKkYm3oLtC9gJXXzfsbACg5X5e4EZZGVAH+YIfa+QA9lsFQTTe3HURF3ag==", - "dev": true, - "peer": true, - "requires": { - "@babel/runtime-corejs3": "^7.12.1" - } - } - } - }, - "cucumber-pretty": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/cucumber-pretty/-/cucumber-pretty-6.0.1.tgz", - "integrity": "sha512-9uOIZ8x3lgCPROqYc7kqe2e7UrH5TZPZCdj5fVPze1XViG9yv8/8MnFsAnVINDYWVhiql8DJHb3UrZfIPHYH/A==", - "dev": true, - "requires": { - "cli-table3": "^0.6.0", - "colors": "^1.4.0", - "figures": "^3.2.0" - } - }, - "cucumber-tag-expressions": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/cucumber-tag-expressions/-/cucumber-tag-expressions-2.0.3.tgz", - "integrity": "sha512-+x5j1IfZrBtbvYHuoUX0rl4nUGxaey6Do9sM0CABmZfDCcWXuuRm1fQeCaklIYQgOFHQ6xOHvDSdkMHHpni6tQ==", - "dev": true, - "peer": true - }, - "cucumber-tsflow": { - "version": "4.0.0-rc.11", - "resolved": "https://registry.npmjs.org/cucumber-tsflow/-/cucumber-tsflow-4.0.0-rc.11.tgz", - "integrity": "sha512-VK/RhJOOxS4KAH6UIkfLsDE2+H7OtP/+cwzx139gldqHP08hoYk/fMwOoXlGWXOOX2O3amJ6RTS0YMF2xCA8Bw==", - "dev": true, - "requires": { - "callsites": "^3.1.0", - "log4js": "^6.3.0", - "source-map-support": "^0.5.19", - "underscore": "^1.8.3" - } - }, - "custom-event": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", - "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", - "dev": true - }, - "d": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "dev": true, - "requires": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - } - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, - "data-uri-to-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", - "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==" - }, - "date-format": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.3.tgz", - "integrity": "sha512-7P3FyqDcfeznLZp2b+OMitV9Sz2lUnsT87WaTat9nVwqsBkTzPG3lPLNwW3en6F4pHUiWzr6vb8CLhjdK9bcxQ==", - "dev": true - }, - "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "requires": { - "ms": "2.1.2" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, - "deep-equal": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz", - "integrity": "sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g==", - "dev": true, - "requires": { - "is-arguments": "^1.0.4", - "is-date-object": "^1.0.1", - "is-regex": "^1.0.4", - "object-is": "^1.0.1", - "object-keys": "^1.1.1", - "regexp.prototype.flags": "^1.2.0" - } - }, - "deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==" - }, - "deepmerge": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", - "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", - "dev": true - }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, - "degenerator": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.2.tgz", - "integrity": "sha512-c0mef3SNQo56t6urUU6tdQAs+ThoD0o9B9MJ8HEt7NQcGEILCRFqQb7ZbP9JAv+QF1Ky5plydhMR/IrqWDm+TQ==", - "requires": { - "ast-types": "^0.13.2", - "escodegen": "^1.8.1", - "esprima": "^4.0.0", - "vm2": "^3.9.8" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" - }, - "di": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", - "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true - }, - "diff-sequences": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz", - "integrity": "sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==", - "dev": true - }, - "dir-glob": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", - "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", - "dev": true, - "requires": { - "path-type": "^4.0.0" - } - }, - "doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "dom-serialize": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", - "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", - "dev": true, - "requires": { - "custom-event": "~1.0.0", - "ent": "~2.2.0", - "extend": "^3.0.0", - "void-elements": "^2.0.0" - } - }, - "duration": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/duration/-/duration-0.2.2.tgz", - "integrity": "sha512-06kgtea+bGreF5eKYgI/36A6pLXggY7oR4p1pq4SmdFBn1ReOL5D8RhG64VrqfTTKNucqqtBAwEj8aB88mcqrg==", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "~0.10.46" - } - }, - "durations": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/durations/-/durations-3.4.2.tgz", - "integrity": "sha512-V/lf7y33dGaypZZetVI1eu7BmvkbC4dItq12OElLRpKuaU5JxQstV2zHwLv8P7cNbQ+KL1WD80zMCTx5dNC4dg==", - "dev": true - }, - "ecc-jsbn": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", - "dev": true, - "requires": { - "jsbn": "~0.1.0", - "safer-buffer": "^2.1.0" - } - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true - }, - "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true - }, - "engine.io": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.5.0.tgz", - "integrity": "sha512-21HlvPUKaitDGE4GXNtQ7PLP0Sz4aWLddMPw2VTyFz1FVZqu/kZsJUO8WNpKuE/OCL7nkfRaOui2ZCJloGznGA==", - "dev": true, - "requires": { - "accepts": "~1.3.4", - "base64id": "2.0.0", - "cookie": "~0.4.1", - "debug": "~4.1.0", - "engine.io-parser": "~2.2.0", - "ws": "~7.4.2" - }, - "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "engine.io-client": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.5.2.tgz", - "integrity": "sha512-QEqIp+gJ/kMHeUun7f5Vv3bteRHppHH/FMBQX/esFj/fuYfjyUKWGMo3VCvIP/V8bE9KcjHmRZrhIz2Z9oNsDA==", - "dev": true, - "requires": { - "component-emitter": "~1.3.0", - "component-inherit": "0.0.3", - "debug": "~3.1.0", - "engine.io-parser": "~2.2.0", - "has-cors": "1.1.0", - "indexof": "0.0.1", - "parseqs": "0.0.6", - "parseuri": "0.0.6", - "ws": "~7.4.2", - "xmlhttprequest-ssl": "~1.6.2", - "yeast": "0.1.2" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "engine.io-parser": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.1.tgz", - "integrity": "sha512-x+dN/fBH8Ro8TFwJ+rkB2AmuVw9Yu2mockR/p3W8f8YtExwFgDvBDi0GWyb4ZLkpahtDGZgtr3zLovanJghPqg==", - "dev": true, - "requires": { - "after": "0.8.2", - "arraybuffer.slice": "~0.0.7", - "base64-arraybuffer": "0.1.4", - "blob": "0.0.5", - "has-binary2": "~1.0.2" - } - }, - "ent": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", - "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", - "dev": true - }, - "error-stack-parser": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", - "integrity": "sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==", - "dev": true, - "requires": { - "stackframe": "^1.3.4" - } - }, - "es5-ext": { - "version": "0.10.53", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", - "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", - "dev": true, - "requires": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.3", - "next-tick": "~1.0.0" - } - }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "dev": true, - "requires": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", - "dev": true - }, - "es6-shim": { - "version": "0.35.6", - "resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.6.tgz", - "integrity": "sha512-EmTr31wppcaIAgblChZiuN/l9Y7DPyw8Xtbg7fIVngn6zMW+IEBJDJngeKC3x6wr0V/vcA2wqeFnaw1bFJbDdA==", - "dev": true - }, - "es6-symbol": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", - "dev": true, - "requires": { - "d": "^1.0.1", - "ext": "^1.1.2" - } - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "requires": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - }, - "dependencies": { - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" - } - } - }, - "eslint": { - "version": "8.37.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.37.0.tgz", - "integrity": "sha512-NU3Ps9nI05GUoVMxcZx1J8CNR6xOvUT4jAUMH5+z8lpp3aEdPVCImKw6PWG4PY+Vfkpr+jvMpxs/qoE7wq0sPw==", - "dev": true, - "requires": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.2", - "@eslint/js": "8.37.0", - "@humanwhocodes/config-array": "^0.11.8", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-visitor-keys": "^3.4.0", - "espree": "^9.5.1", - "esquery": "^1.4.2", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "requires": { - "is-glob": "^4.0.3" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - } - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1" - } - } - } - }, - "eslint-plugin-mocha": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-mocha/-/eslint-plugin-mocha-10.0.3.tgz", - "integrity": "sha512-9mM7PZGxfejpjey+MrG0Cu3Lc8MyA5E2s7eUCdHXgS4SY/H9zLuwa7wVAjnEaoDjbBilA+0bPEB+iMO7lBUPcg==", - "dev": true, - "requires": { - "eslint-utils": "^3.0.0", - "ramda": "^0.27.1" - } - }, - "eslint-plugin-prettier": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz", - "integrity": "sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==", - "dev": true, - "requires": { - "prettier-linter-helpers": "^1.0.0" - } - }, - "eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - } - }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true - } - } - }, - "eslint-visitor-keys": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", - "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", - "dev": true - }, - "espree": { - "version": "9.5.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", - "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", - "dev": true, - "requires": { - "acorn": "^8.8.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.0" - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" - }, - "esquery": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", - "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", - "dev": true, - "requires": { - "estraverse": "^5.1.0" - } - }, - "esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "requires": { - "estraverse": "^5.2.0" - } - }, - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - }, - "estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" - }, - "eventemitter3": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", - "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", - "dev": true - }, - "expect": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-27.5.1.tgz", - "integrity": "sha512-E1q5hSUG2AmYQwQJ041nvgpkODHQvB+RKlB4IYdru6uJsyFTRyZAP463M+1lINorwbqAmUggi6+WwkD8lCS/Dw==", - "dev": true, - "requires": { - "@jest/types": "^27.5.1", - "jest-get-type": "^27.5.1", - "jest-matcher-utils": "^27.5.1", - "jest-message-util": "^27.5.1" - } - }, - "ext": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz", - "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", - "dev": true, - "requires": { - "type": "^2.5.0" - }, - "dependencies": { - "type": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz", - "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==", - "dev": true - } - } - }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "extract-zip": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", - "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", - "dev": true, - "requires": { - "concat-stream": "^1.6.2", - "debug": "^2.6.9", - "mkdirp": "^0.5.4", - "yauzl": "^2.10.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "fast-diff": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", - "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", - "dev": true - }, - "fast-glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", - "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", - "dev": true, - "requires": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - } - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" - }, - "fast-safe-stringify": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", - "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" - }, - "fastq": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", - "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", - "dev": true, - "requires": { - "reusify": "^1.0.4" - } - }, - "fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", - "dev": true, - "requires": { - "pend": "~1.2.0" - } - }, - "figures": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", - "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", - "dev": true, - "requires": { - "flat-cache": "^3.0.4" - } - }, - "file-uri-to-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", - "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==" - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", - "dev": true, - "requires": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "statuses": "~1.5.0", - "unpipe": "~1.0.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true - }, - "flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", - "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", - "dev": true, - "requires": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" - } - }, - "flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", - "dev": true - }, - "follow-redirects": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", - "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true - }, - "form-data": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", - "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, - "formidable": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", - "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==" - }, - "fs-extra": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "optional": true - }, - "ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", - "requires": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1" - } - }, - "get-uri": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", - "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", - "requires": { - "@tootallnate/once": "1", - "data-uri-to-buffer": "3", - "debug": "4", - "file-uri-to-path": "2", - "fs-extra": "^8.1.0", - "ftp": "^0.3.10" - }, - "dependencies": { - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "requires": { - "graceful-fs": "^4.1.6" - } - } - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0" - } - }, - "gherkin": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/gherkin/-/gherkin-5.0.0.tgz", - "integrity": "sha512-Y+93z2Nh+TNIKuKEf+6M0FQrX/z0Yv9C2LFfc5NlcGJWRrrTeI/jOg2374y1FOw6ZYQ3RgJBezRkli7CLDubDA==", - "dev": true, - "peer": true - }, - "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "requires": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - } - }, - "graceful-fs": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==" - }, - "grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true - }, - "har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "dev": true, - "requires": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - } - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-binary2": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", - "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", - "dev": true, - "requires": { - "isarray": "2.0.1" - }, - "dependencies": { - "isarray": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", - "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", - "dev": true - } - } - }, - "has-cors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", - "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-symbols": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", - "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", - "dev": true - }, - "has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", - "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", - "dev": true, - "requires": { - "has-symbols": "^1.0.2" - } - }, - "hasha": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", - "dev": true, - "requires": { - "is-stream": "^1.0.1", - "pinkie-promise": "^2.0.0" - }, - "dependencies": { - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - } - } - }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, - "http-errors": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", - "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.1" - } - }, - "http-proxy": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", - "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", - "dev": true, - "requires": { - "eventemitter3": "^4.0.0", - "follow-redirects": "^1.0.0", - "requires-port": "^1.0.0" - } - }, - "http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", - "requires": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" - } - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, - "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "requires": { - "agent-base": "6", - "debug": "4" - } - }, - "humanize-ms": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", - "integrity": "sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=", - "requires": { - "ms": "^2.0.0" - } - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" - }, - "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", - "dev": true - }, - "import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true - }, - "indexof": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" - }, - "is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "dev": true, - "requires": { - "has": "^1.0.3" - } - }, - "is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", - "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "is-generator": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-generator/-/is-generator-1.0.3.tgz", - "integrity": "sha1-wUwhBX7TbjKNuANHlmxpP4hjifM=", - "dev": true - }, - "is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", - "dev": true - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true - }, - "is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true - }, - "is-reference": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", - "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", - "dev": true, - "requires": { - "@types/estree": "*" - } - }, - "is-regex": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", - "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true - }, - "is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isbinaryfile": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.8.tgz", - "integrity": "sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w==", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true - }, - "jest-diff": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.5.1.tgz", - "integrity": "sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==", - "dev": true, - "requires": { - "chalk": "^4.0.0", - "diff-sequences": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "jest-get-type": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.5.1.tgz", - "integrity": "sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==", - "dev": true - }, - "jest-matcher-utils": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz", - "integrity": "sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw==", - "dev": true, - "requires": { - "chalk": "^4.0.0", - "jest-diff": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "jest-message-util": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-27.5.1.tgz", - "integrity": "sha512-rMyFe1+jnyAAf+NHwTclDz0eAaLkVDdKVHHBFWsBWHnnh5YeJMNWWsv7AbFYXfK3oTqvL7VTWkhNLu1jX24D+g==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^27.5.1", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^27.5.1", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "jest-worker": { - "version": "26.6.2", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", - "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", - "dev": true, - "requires": { - "@types/node": "*", - "merge-stream": "^2.0.0", - "supports-color": "^7.0.0" - }, - "dependencies": { - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "js-sdsl": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.0.tgz", - "integrity": "sha512-FfVSdx6pJ41Oa+CF7RDaFmTnCaFhua+SNYQX74riGOpl96x+2jQCqEfQ2bnXu/5DPCqlRuiqyvTJM0Qjz26IVg==", - "dev": true - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true - }, - "json-schema": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", - "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, - "jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "jsprim": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", - "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", - "dev": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.4.0", - "verror": "1.10.0" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - } - } - }, - "just-extend": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.2.1.tgz", - "integrity": "sha512-g3UB796vUFIY90VIv/WX3L2c8CS2MdWUww3CNrYmqza1Fg0DURc2K/O4YrnklBdQarSJ/y8JnJYDGc+1iumQjg==", - "dev": true - }, - "karma": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/karma/-/karma-5.2.3.tgz", - "integrity": "sha512-tHdyFADhVVPBorIKCX8A37iLHxc6RBRphkSoQ+MLKdAtFn1k97tD8WUGi1KlEtDZKL3hui0qhsY9HXUfSNDYPQ==", - "dev": true, - "requires": { - "body-parser": "^1.19.0", - "braces": "^3.0.2", - "chokidar": "^3.4.2", - "colors": "^1.4.0", - "connect": "^3.7.0", - "di": "^0.0.1", - "dom-serialize": "^2.2.1", - "glob": "^7.1.6", - "graceful-fs": "^4.2.4", - "http-proxy": "^1.18.1", - "isbinaryfile": "^4.0.6", - "lodash": "^4.17.19", - "log4js": "^6.2.1", - "mime": "^2.4.5", - "minimatch": "^3.0.4", - "qjobs": "^1.2.0", - "range-parser": "^1.2.1", - "rimraf": "^3.0.2", - "socket.io": "^2.3.0", - "source-map": "^0.6.1", - "tmp": "0.2.1", - "ua-parser-js": "0.7.22", - "yargs": "^15.3.1" - } - }, - "karma-chai": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz", - "integrity": "sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o=", - "dev": true, - "requires": {} - }, - "karma-chrome-launcher": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.0.tgz", - "integrity": "sha512-3dPs/n7vgz1rxxtynpzZTvb9y/GIaW8xjAwcIGttLbycqoFtI7yo1NGnQi6oFTherRE+GIhCAHZC4vEqWGhNvg==", - "dev": true, - "requires": { - "which": "^1.2.1" - } - }, - "karma-mocha": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-2.0.1.tgz", - "integrity": "sha512-Tzd5HBjm8his2OA4bouAsATYEpZrp9vC7z5E5j4C5Of5Rrs1jY67RAwXNcVmd/Bnk1wgvQRou0zGVLey44G4tQ==", - "dev": true, - "requires": { - "minimist": "^1.2.3" - } - }, - "karma-phantomjs-launcher": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz", - "integrity": "sha1-0jyjSAG9qYY60xjju0vUBisTrNI=", - "dev": true, - "requires": { - "lodash": "^4.0.1", - "phantomjs-prebuilt": "^2.1.7" - } - }, - "karma-sinon-chai": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/karma-sinon-chai/-/karma-sinon-chai-2.0.2.tgz", - "integrity": "sha512-SDgh6V0CUd+7ruL1d3yG6lFzmJNGRNQuEuCYXLaorruNP9nwQfA7hpsp4clx4CbOo5Gsajh3qUOT7CrVStUKMw==", - "dev": true, - "requires": {} - }, - "karma-sourcemap-loader": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.8.tgz", - "integrity": "sha512-zorxyAakYZuBcHRJE+vbrK2o2JXLFWK8VVjiT/6P+ltLBUGUvqTEkUiQ119MGdOrK7mrmxXHZF1/pfT6GgIZ6g==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2" - } - }, - "karma-spec-reporter": { - "version": "0.0.32", - "resolved": "https://registry.npmjs.org/karma-spec-reporter/-/karma-spec-reporter-0.0.32.tgz", - "integrity": "sha1-LpxyB+pyZ3EmAln4K+y1QyCeRAo=", - "dev": true, - "requires": { - "colors": "^1.1.2" - } - }, - "kew": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", - "dev": true - }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.9" - } - }, - "knuth-shuffle-seeded": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/knuth-shuffle-seeded/-/knuth-shuffle-seeded-1.0.6.tgz", - "integrity": "sha1-AfG2VzOqdUDuCNiwF0Fk0iCB5OE=", - "dev": true, - "requires": { - "seed-random": "~2.2.0" - } - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "lil-uuid": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/lil-uuid/-/lil-uuid-0.1.1.tgz", - "integrity": "sha1-+e3PI/AOQr9D8PhD2Y2LU/M0HxY=" - }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true - }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "log4js": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.1.tgz", - "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", - "dev": true, - "requires": { - "date-format": "^4.0.3", - "debug": "^4.3.3", - "flatted": "^3.2.4", - "rfdc": "^1.3.0", - "streamroller": "^3.0.2" - } - }, - "lolex": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.2.0.tgz", - "integrity": "sha512-gKO5uExCXvSm6zbF562EvM+rd1kQDnB9AZBbiQVzf1ZmdDpxUSvpnAaVOP83N/31mRK8Ml8/VE8DMvsAZQ+7wg==", - "dev": true - }, - "lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dev": true, - "requires": { - "tslib": "^2.0.3" - } - }, - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "requires": { - "yallist": "^3.0.2" - } - }, - "magic-string": { - "version": "0.25.7", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", - "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", - "dev": true, - "requires": { - "sourcemap-codec": "^1.4.4" - } - }, - "make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true - }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "dev": true - }, - "merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true - }, - "merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true - }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" - }, - "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "dev": true, - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" - } - }, - "mime": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", - "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==" - }, - "mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" - }, - "mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", - "requires": { - "mime-db": "1.51.0" - } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "mocha": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.1.tgz", - "integrity": "sha512-T7uscqjJVS46Pq1XDXyo9Uvey9gd3huT/DD9cYBb4K2Xc/vbKRPUWK067bxDQRK0yIz6Jxk73IrnimvASzBNAQ==", - "dev": true, - "requires": { - "@ungap/promise-all-settled": "1.1.2", - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.3", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.2.0", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", - "minimatch": "3.0.4", - "ms": "2.1.3", - "nanoid": "3.2.0", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - } - } - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "mz": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", - "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", - "dev": true, - "requires": { - "any-promise": "^1.0.0", - "object-assign": "^4.0.1", - "thenify-all": "^1.0.0" - } - }, - "nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", - "dev": true - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "dev": true - }, - "netmask": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", - "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==" - }, - "next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", - "dev": true - }, - "nise": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.5.3.tgz", - "integrity": "sha512-Ymbac/94xeIrMf59REBPOv0thr+CJVFMhrlAkW/gjCIE58BGQdCj0x7KRCb3yz+Ga2Rz3E9XXSvUyyxqqhjQAQ==", - "dev": true, - "requires": { - "@sinonjs/formatio": "^3.2.1", - "@sinonjs/text-encoding": "^0.7.1", - "just-extend": "^4.0.2", - "lolex": "^5.0.1", - "path-to-regexp": "^1.7.0" - }, - "dependencies": { - "lolex": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-5.1.2.tgz", - "integrity": "sha512-h4hmjAvHTmd+25JSwrtTIuwbKdwg5NzZVRMLn9saij4SZaepCrTCxPr35H/3bjwfMJtN+t3CX8672UIkglz28A==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.7.0" - } - } - } - }, - "no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dev": true, - "requires": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, - "nock": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/nock/-/nock-9.6.1.tgz", - "integrity": "sha512-EDgl/WgNQ0C1BZZlASOQkQdE6tAWXJi8QQlugqzN64JJkvZ7ILijZuG24r4vCC7yOfnm6HKpne5AGExLGCeBWg==", - "dev": true, - "requires": { - "chai": "^4.1.2", - "debug": "^3.1.0", - "deep-equal": "^1.0.0", - "json-stringify-safe": "^5.0.1", - "lodash": "^4.17.5", - "mkdirp": "^0.5.0", - "propagate": "^1.0.0", - "qs": "^6.5.1", - "semver": "^5.5.0" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } - } - }, - "node-fetch": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", - "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", - "dev": true, - "requires": { - "whatwg-url": "^5.0.0" - } - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - }, - "oauth-sign": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", - "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "object-is": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", - "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "dev": true, - "requires": { - "ee-first": "1.1.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "pac-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", - "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", - "requires": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4", - "get-uri": "3", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "5", - "pac-resolver": "^5.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "5" - } - }, - "pac-resolver": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.0.tgz", - "integrity": "sha512-H+/A6KitiHNNW+bxBKREk2MCGSxljfqRX76NjummWEYIat7ldVXRU3dhRIE3iXZ0nvGBk6smv3nntxKkzRL8NA==", - "requires": { - "degenerator": "^3.0.1", - "ip": "^1.1.5", - "netmask": "^2.0.1" - } - }, - "pad-right": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/pad-right/-/pad-right-0.2.2.tgz", - "integrity": "sha1-b7ySQEXSRPKiokRQMGDTv8YAl3Q=", - "dev": true, - "requires": { - "repeat-string": "^1.5.2" - } - }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "requires": { - "callsites": "^3.0.0" - } - }, - "parseqs": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz", - "integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w==", - "dev": true - }, - "parseuri": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz", - "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow==", - "dev": true - }, - "parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true - }, - "path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "dev": true, - "requires": { - "isarray": "0.0.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } - } - }, - "path-type": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", - "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", - "dev": true - }, - "pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true - }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true - }, - "phantomjs-prebuilt": { - "version": "2.1.16", - "resolved": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz", - "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", - "dev": true, - "requires": { - "es6-promise": "^4.0.3", - "extract-zip": "^1.6.5", - "fs-extra": "^1.0.0", - "hasha": "^2.2.0", - "kew": "^0.7.0", - "progress": "^1.1.8", - "request": "^2.81.0", - "request-progress": "^2.0.1", - "which": "^1.2.10" - }, - "dependencies": { - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - } - } - }, - "picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "^2.0.0" - } - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" - }, - "prettier": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", - "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", - "dev": true - }, - "prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", - "dev": true, - "requires": { - "fast-diff": "^1.1.2" - } - }, - "pretty-format": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", - "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^17.0.1" - }, - "dependencies": { - "ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true - }, - "react-is": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", - "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", - "dev": true - } - } - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true - }, - "propagate": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/propagate/-/propagate-1.0.0.tgz", - "integrity": "sha1-AMLa7t2iDofjeCs0Stuhzd1q1wk=", - "dev": true - }, - "proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", - "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", - "requires": { - "agent-base": "^6.0.0", - "debug": "4", - "http-proxy-agent": "^4.0.0", - "https-proxy-agent": "^5.0.0", - "lru-cache": "^5.1.1", - "pac-proxy-agent": "^5.0.0", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^5.0.0" - } - }, - "proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, - "psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", - "dev": true - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "qjobs": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", - "integrity": "sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg==", - "dev": true - }, - "qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==" - }, - "queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true - }, - "ramda": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.27.2.tgz", - "integrity": "sha512-SbiLPU40JuJniHexQSAgad32hfwd+DRUdwF2PlVuI5RZD0/vahUco7R8vD86J/tcEKKF9vZrUVwgtmGCqlCKyA==", - "dev": true - }, - "randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "requires": { - "safe-buffer": "^5.1.0" - } - }, - "range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true - }, - "raw-body": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", - "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", - "requires": { - "bytes": "3.1.2", - "http-errors": "1.8.1", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - } - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "reflect-metadata": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", - "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", - "dev": true - }, - "regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true, - "peer": true - }, - "regexp-match-indices": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regexp-match-indices/-/regexp-match-indices-1.0.2.tgz", - "integrity": "sha512-DwZuAkt8NF5mKwGGER1EGh2PRqyvhRhhLviH+R8y8dIuaQROlUfXjt4s9ZTXstIsSkptf06BSvwcEmmfheJJWQ==", - "dev": true, - "requires": { - "regexp-tree": "^0.1.11" - } - }, - "regexp-tree": { - "version": "0.1.24", - "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.24.tgz", - "integrity": "sha512-s2aEVuLhvnVJW6s/iPgEGK6R+/xngd2jNQ+xy4bXNDKxZKJH6jpPHY6kVeVv1IeLCHgswRj+Kl3ELaDjG6V1iw==", - "dev": true - }, - "regexp.prototype.flags": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.1.tgz", - "integrity": "sha512-pMR7hBVUUGI7PMA37m2ofIdQCsomVnas+Jn5UPGAHQ+/LlwKm/aTLJHdasmHRzlfeZwHiAOaRSo2rbBDm3nNUQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "request": { - "version": "2.88.2", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", - "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", - "dev": true, - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.8.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.6", - "extend": "~3.0.2", - "forever-agent": "~0.6.1", - "form-data": "~2.3.2", - "har-validator": "~5.1.3", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.19", - "oauth-sign": "~0.9.0", - "performance-now": "^2.1.0", - "qs": "~6.5.2", - "safe-buffer": "^5.1.2", - "tough-cookie": "~2.5.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.3.2" - }, - "dependencies": { - "qs": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", - "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", - "dev": true - }, - "uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "dev": true - } - } - }, - "request-progress": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", - "dev": true, - "requires": { - "throttleit": "^1.0.0" - } - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, - "requires-port": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true - }, - "resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "dev": true, - "requires": { - "is-core-module": "^2.8.1", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - }, - "resolve-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/resolve-pkg/-/resolve-pkg-2.0.0.tgz", - "integrity": "sha512-+1lzwXehGCXSeryaISr6WujZzowloigEofRB+dj75y9RRa/obVcYgbHJd53tdYw8pvZj8GojXaaENws8Ktw/hQ==", - "dev": true, - "requires": { - "resolve-from": "^5.0.0" - }, - "dependencies": { - "resolve-from": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", - "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", - "dev": true - } - } - }, - "reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true - }, - "rfdc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", - "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", - "dev": true - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "rollup": { - "version": "2.68.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.68.0.tgz", - "integrity": "sha512-XrMKOYK7oQcTio4wyTz466mucnd8LzkiZLozZ4Rz0zQD+HeX4nUK4B8GrTX/2EvN2/vBF/i2WnaXboPxo0JylA==", - "dev": true, - "requires": { - "fsevents": "~2.3.2" - } - }, - "rollup-plugin-gzip": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-gzip/-/rollup-plugin-gzip-3.0.1.tgz", - "integrity": "sha512-yzyrbe5cn/3yTqtGpVb+0kQXiqKLZpNpRTGpItc11b8c9IhawpjZPPLMkh1Q7gl6UsHIVjcw9LeEdvom9H3klw==", - "dev": true, - "requires": {} - }, - "rollup-plugin-terser": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", - "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.10.4", - "jest-worker": "^26.2.1", - "serialize-javascript": "^4.0.0", - "terser": "^5.0.0" - } - }, - "run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "requires": { - "queue-microtask": "^1.2.2" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "seed-random": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/seed-random/-/seed-random-2.2.0.tgz", - "integrity": "sha1-KpsZ4lCoFwmSMaW5mk2vgLf77VQ=", - "dev": true - }, - "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "requires": { - "lru-cache": "^6.0.0" - }, - "dependencies": { - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "requires": { - "yallist": "^4.0.0" - } - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - } - } - }, - "serialize-error": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-4.1.0.tgz", - "integrity": "sha512-5j9GgyGsP9vV9Uj1S0lDCvlsd+gc2LEPVK7HHHte7IyPwOD4lVQFeaX143gx3U5AnoCi+wbcb3mvaxVysjpxEw==", - "dev": true, - "peer": true, - "requires": { - "type-fest": "^0.3.0" - }, - "dependencies": { - "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", - "dev": true, - "peer": true - } - } - }, - "serialize-javascript": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", - "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, - "setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "sinon": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.5.0.tgz", - "integrity": "sha512-AoD0oJWerp0/rY9czP/D6hDTTUYGpObhZjMpd7Cl/A6+j0xBE+ayL/ldfggkBXUs0IkvIiM1ljM8+WkOc5k78Q==", - "dev": true, - "requires": { - "@sinonjs/commons": "^1.4.0", - "@sinonjs/formatio": "^3.2.1", - "@sinonjs/samsam": "^3.3.3", - "diff": "^3.5.0", - "lolex": "^4.2.0", - "nise": "^1.5.2", - "supports-color": "^5.5.0" - }, - "dependencies": { - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - } - } - }, - "sinon-chai": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-3.7.0.tgz", - "integrity": "sha512-mf5NURdUaSdnatJx3uhoBOrY9dtL19fiOtAdT1Azxg3+lNJFiuN0uzaU3xX1LeAfL17kHQhTAJgpsfhbMJMY2g==", - "dev": true, - "requires": {} - }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true - }, - "smart-buffer": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", - "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==" - }, - "socket.io": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.4.1.tgz", - "integrity": "sha512-Si18v0mMXGAqLqCVpTxBa8MGqriHGQh8ccEOhmsmNS3thNCGBwO8WGrwMibANsWtQQ5NStdZwHqZR3naJVFc3w==", - "dev": true, - "requires": { - "debug": "~4.1.0", - "engine.io": "~3.5.0", - "has-binary2": "~1.0.2", - "socket.io-adapter": "~1.1.0", - "socket.io-client": "2.4.0", - "socket.io-parser": "~3.4.0" - }, - "dependencies": { - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "socket.io-adapter": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz", - "integrity": "sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g==", - "dev": true - }, - "socket.io-client": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.4.0.tgz", - "integrity": "sha512-M6xhnKQHuuZd4Ba9vltCLT9oa+YvTsP8j9NcEiLElfIg8KeYPyhWOes6x4t+LTAC8enQbE/995AdTem2uNyKKQ==", - "dev": true, - "requires": { - "backo2": "1.0.2", - "component-bind": "1.0.0", - "component-emitter": "~1.3.0", - "debug": "~3.1.0", - "engine.io-client": "~3.5.0", - "has-binary2": "~1.0.2", - "indexof": "0.0.1", - "parseqs": "0.0.6", - "parseuri": "0.0.6", - "socket.io-parser": "~3.3.0", - "to-array": "0.1.4" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "isarray": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", - "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", - "dev": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "socket.io-parser": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.2.tgz", - "integrity": "sha512-FJvDBuOALxdCI9qwRrO/Rfp9yfndRtc1jSgVgV8FDraihmSP/MLGD5PEuJrNfjALvcQ+vMDM/33AWOYP/JSjDg==", - "dev": true, - "requires": { - "component-emitter": "~1.3.0", - "debug": "~3.1.0", - "isarray": "2.0.1" - } - } - } - }, - "socket.io-parser": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.4.1.tgz", - "integrity": "sha512-11hMgzL+WCLWf1uFtHSNvliI++tcRUWdoeYuwIl+Axvwy9z2gQM+7nJyN3STj1tLj5JyIUH8/gpDGxzAlDdi0A==", - "dev": true, - "requires": { - "component-emitter": "1.2.1", - "debug": "~4.1.0", - "isarray": "2.0.1" - }, - "dependencies": { - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "isarray": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", - "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=", - "dev": true - } - } - }, - "socks": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz", - "integrity": "sha512-zDZhHhZRY9PxRruRMR7kMhnf3I8hDs4S3f9RecfnGxvcBHQcKcIH/oUcEWffsfl1XxdYlA7nnlGbbTvPz9D8gA==", - "requires": { - "ip": "^1.1.5", - "smart-buffer": "^4.2.0" - } - }, - "socks-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", - "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", - "requires": { - "agent-base": "^6.0.2", - "debug": "4", - "socks": "^2.3.3" - } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "devOptional": true - }, - "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "sshpk": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", - "integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==", - "dev": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "safer-buffer": "^2.0.2", - "tweetnacl": "~0.14.0" - } - }, - "stack-chain": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-2.0.0.tgz", - "integrity": "sha512-GGrHXePi305aW7XQweYZZwiRwR7Js3MWoK/EHzzB9ROdc75nCnjSJVi21rdAGxFl+yCx2L2qdfl5y7NO4lTyqg==", - "dev": true - }, - "stack-generator": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/stack-generator/-/stack-generator-2.0.5.tgz", - "integrity": "sha512-/t1ebrbHkrLrDuNMdeAcsvynWgoH/i4o8EGGfX7dEYDoTXOYVAkEpFdtshlvabzc6JlJ8Kf9YdFEoz7JkzGN9Q==", - "dev": true, - "requires": { - "stackframe": "^1.1.1" - } - }, - "stack-utils": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz", - "integrity": "sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA==", - "dev": true, - "requires": { - "escape-string-regexp": "^2.0.0" - }, - "dependencies": { - "escape-string-regexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", - "dev": true - } - } - }, - "stackframe": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", - "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==", - "dev": true - }, - "stacktrace-gps": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/stacktrace-gps/-/stacktrace-gps-3.0.4.tgz", - "integrity": "sha512-qIr8x41yZVSldqdqe6jciXEaSCKw1U8XTXpjDuy0ki/apyTn/r3w9hDAAQOhZdxvsC93H+WwwEu5cq5VemzYeg==", - "dev": true, - "requires": { - "source-map": "0.5.6", - "stackframe": "^1.1.1" - }, - "dependencies": { - "source-map": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", - "dev": true - } - } - }, - "stacktrace-js": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/stacktrace-js/-/stacktrace-js-2.0.2.tgz", - "integrity": "sha512-Je5vBeY4S1r/RnLydLl0TBTi3F2qdfWmYsGvtfZgEI+SCprPppaIhQf5nGcal4gI4cGpCV/duLcAzT1np6sQqg==", - "dev": true, - "requires": { - "error-stack-parser": "^2.0.6", - "stack-generator": "^2.0.5", - "stacktrace-gps": "^3.0.4" - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" - }, - "streamroller": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.0.2.tgz", - "integrity": "sha512-ur6y5S5dopOaRXBuRIZ1u6GC5bcEXHRZKgfBjfCglMhmIf+roVCECjvkEYzNQOXIN2/JPnkMPW/8B3CZoKaEPA==", - "dev": true, - "requires": { - "date-format": "^4.0.3", - "debug": "^4.1.1", - "fs-extra": "^10.0.0" - }, - "dependencies": { - "fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - } - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "string-argv": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", - "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "dependencies": { - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - } - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true, - "optional": true - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true - }, - "superagent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-6.1.0.tgz", - "integrity": "sha512-OUDHEssirmplo3F+1HWKUrUjvnQuA+nZI6i/JJBdXb5eq9IyEQwPyPpqND+SSsxf6TygpBEkUjISVRN4/VOpeg==", - "requires": { - "component-emitter": "^1.3.0", - "cookiejar": "^2.1.2", - "debug": "^4.1.1", - "fast-safe-stringify": "^2.0.7", - "form-data": "^3.0.0", - "formidable": "^1.2.2", - "methods": "^1.1.2", - "mime": "^2.4.6", - "qs": "^6.9.4", - "readable-stream": "^3.6.0", - "semver": "^7.3.2" - }, - "dependencies": { - "form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, - "superagent-proxy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/superagent-proxy/-/superagent-proxy-3.0.0.tgz", - "integrity": "sha512-wAlRInOeDFyd9pyonrkJspdRAxdLrcsZ6aSnS+8+nu4x1aXbz6FWSTT9M6Ibze+eG60szlL7JA8wEIV7bPWuyQ==", - "requires": { - "debug": "^4.3.2", - "proxy-agent": "^5.0.0" - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true - }, - "terser": { - "version": "5.11.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.11.0.tgz", - "integrity": "sha512-uCA9DLanzzWSsN1UirKwylhhRz3aKPInlfmpGfw8VN6jHsAtu8HJtIpeeHHK23rxnE/cDc+yvmq5wqkIC6Kn0A==", - "dev": true, - "requires": { - "acorn": "^8.5.0", - "commander": "^2.20.0", - "source-map": "~0.7.2", - "source-map-support": "~0.5.20" - }, - "dependencies": { - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", - "dev": true - } - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "thenify": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", - "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", - "dev": true, - "requires": { - "any-promise": "^1.0.0" - } - }, - "thenify-all": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", - "integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=", - "dev": true, - "requires": { - "thenify": ">= 3.1.0 < 4" - } - }, - "throttleit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", - "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", - "dev": true - }, - "title-case": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/title-case/-/title-case-2.1.1.tgz", - "integrity": "sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==", - "dev": true, - "peer": true, - "requires": { - "no-case": "^2.2.0", - "upper-case": "^1.0.3" - }, - "dependencies": { - "lower-case": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-1.1.4.tgz", - "integrity": "sha512-2Fgx1Ycm599x+WGpIYwJOvsjmXFzTSc34IwDWALRA/8AopUKAVPwfJ+h5+f85BCp0PWmmJcWzEpxOpoXycMpdA==", - "dev": true, - "peer": true - }, - "no-case": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz", - "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==", - "dev": true, - "peer": true, - "requires": { - "lower-case": "^1.1.1" - } - } - } - }, - "tmp": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", - "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", - "dev": true, - "requires": { - "rimraf": "^3.0.0" - } - }, - "to-array": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", - "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", - "dev": true - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" - }, - "tough-cookie": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", - "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "dev": true, - "requires": { - "psl": "^1.1.28", - "punycode": "^2.1.1" - } - }, - "tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", - "dev": true - }, - "ts-dedent": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", - "integrity": "sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==", - "dev": true - }, - "ts-mocha": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-9.0.2.tgz", - "integrity": "sha512-WyQjvnzwrrubl0JT7EC1yWmNpcsU3fOuBFfdps30zbmFBgKniSaSOyZMZx+Wq7kytUs5CY+pEbSYEbGfIKnXTw==", - "dev": true, - "requires": { - "ts-node": "7.0.1", - "tsconfig-paths": "^3.5.0" - }, - "dependencies": { - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - }, - "ts-node": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", - "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", - "dev": true, - "requires": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" - } - }, - "yn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", - "integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=", - "dev": true - } - } - }, - "ts-node": { - "version": "10.9.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", - "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, - "requires": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - } - }, - "tsconfig-paths": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz", - "integrity": "sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg==", - "dev": true, - "optional": true, - "requires": { - "@types/json5": "^0.0.29", - "json5": "^1.0.1", - "minimist": "^1.2.0", - "strip-bom": "^3.0.0" - }, - "dependencies": { - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "optional": true, - "requires": { - "minimist": "^1.2.0" - } - } - } - }, - "tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" - }, - "tsutils": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", - "dev": true, - "requires": { - "tslib": "^1.8.1" - }, - "dependencies": { - "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - } - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true - }, - "type": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - }, - "type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dev": true, - "requires": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - } - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "typescript": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", - "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", - "dev": true - }, - "ua-parser-js": { - "version": "0.7.22", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.22.tgz", - "integrity": "sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q==", - "dev": true - }, - "underscore": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.2.tgz", - "integrity": "sha512-ekY1NhRzq0B08g4bGuX4wd2jZx5GnKz6mKSqFL4nqBlfyMGiG10gDFhDTMEfYmDL6Jy0FUIZp7wiRB+0BP7J2g==", - "dev": true - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, - "upper-case": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/upper-case/-/upper-case-1.1.3.tgz", - "integrity": "sha512-WRbjgmYzgXkCV7zNVpy5YgrHgbBv126rMALQQMrmzOVC4GM2waQ9x7xtm8VU+1yF2kWyPzI9zbZ48n4vSxwfSA==", - "dev": true, - "peer": true - }, - "upper-case-first": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", - "integrity": "sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg==", - "dev": true, - "requires": { - "tslib": "^2.0.3" - } - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - }, - "util-arity": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/util-arity/-/util-arity-1.1.0.tgz", - "integrity": "sha1-WdAa8f2z/t4KxOYysKtfbOl8kzA=", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", - "dev": true - }, - "uuid": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", - "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", - "dev": true, - "peer": true - }, - "v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true - }, - "verror": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.1.tgz", - "integrity": "sha512-veufcmxri4e3XSrT0xwfUR7kguIkaxBeosDg00yDWhk49wdwkSUrvvsm7nc75e1PUyvIeZj6nS8VQRYz2/S4Xg==", - "dev": true, - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - } - } - }, - "vm2": { - "version": "3.9.8", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.8.tgz", - "integrity": "sha512-/1PYg/BwdKzMPo8maOZ0heT7DLI0DAFTm7YQaz/Lim9oIaFZsJs3EdtalvXuBfZwczNwsYhju75NW4d6E+4q+w==", - "requires": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - } - }, - "void-elements": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", - "dev": true - }, - "webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", - "dev": true - }, - "whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", - "dev": true, - "requires": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" - }, - "workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", - "dev": true - }, - "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - } - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "ws": { - "version": "7.4.6", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", - "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", - "dev": true, - "requires": {} - }, - "xmlhttprequest-ssl": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.6.3.tgz", - "integrity": "sha512-3XfeQE/wNkvrIktn2Kf0869fC0BN6UpydVasGIeSm2B1Llihf7/0UfZM+eCkOw3P7bP4+qPgqhm7ZoxuJtFU0Q==", - "dev": true - }, - "xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=" - }, - "y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true - }, - "yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" - }, - "yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, - "requires": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "dependencies": { - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - } - } - }, - "yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", - "dev": true - }, - "yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "requires": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "dependencies": { - "camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true - }, - "decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true - } - } - }, - "yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", - "dev": true, - "requires": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, - "yeast": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", - "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", - "dev": true - }, - "yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true - }, - "yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true - } } } From f815ad895ea309491fb286830b592b96a997e3b2 Mon Sep 17 00:00:00 2001 From: Mohit Tejani Date: Tue, 16 Jan 2024 08:29:43 +0530 Subject: [PATCH 62/63] removed flow_interfaces reference --- src/core/components/deduping_manager.js | 1 - src/core/components/push_payload.js | 1 - src/core/components/reconnection_manager.js | 1 - src/core/endpoints/access_manager/audit.js | 1 - src/core/endpoints/access_manager/grant.js | 2 -- src/core/endpoints/actions/add_message_action.js | 1 - src/core/endpoints/actions/get_message_actions.js | 2 -- src/core/endpoints/actions/remove_message_action.js | 1 - src/core/endpoints/channel_groups/add_channels.js | 2 -- src/core/endpoints/channel_groups/delete_group.js | 1 - src/core/endpoints/channel_groups/list_channels.js | 2 -- src/core/endpoints/channel_groups/list_groups.js | 1 - src/core/endpoints/channel_groups/remove_channels.js | 2 -- src/core/endpoints/fetch_messages.js | 8 -------- src/core/endpoints/history/delete_messages.js | 1 - src/core/endpoints/history/get_history.js | 2 -- src/core/endpoints/presence/get_state.js | 1 - src/core/endpoints/presence/heartbeat.js | 1 - src/core/endpoints/presence/here_now.js | 2 -- src/core/endpoints/presence/leave.js | 1 - src/core/endpoints/presence/where_now.js | 2 -- src/core/endpoints/publish.js | 2 -- src/core/endpoints/push/add_push_channels.js | 1 - src/core/endpoints/push/list_push_channels.js | 2 -- src/core/endpoints/push/remove_device.js | 1 - src/core/endpoints/push/remove_push_channels.js | 1 - src/core/endpoints/signal.js | 1 - src/core/endpoints/subscribe.js | 9 --------- src/core/endpoints/time.js | 2 -- src/nativescript/index.js | 1 - src/networking/index.js | 2 -- src/networking/modules/nativescript.js | 1 - src/networking/modules/titanium.js | 1 - 33 files changed, 60 deletions(-) diff --git a/src/core/components/deduping_manager.js b/src/core/components/deduping_manager.js index 2cadb2eb6..7ac8aa613 100644 --- a/src/core/components/deduping_manager.js +++ b/src/core/components/deduping_manager.js @@ -1,7 +1,6 @@ /* */ import Config from './config'; -import { SubscribeMessage } from '../flow_interfaces'; const hashCode = (payload) => { let hash = 0; diff --git a/src/core/components/push_payload.js b/src/core/components/push_payload.js index 5544da253..c9ab4fc85 100644 --- a/src/core/components/push_payload.js +++ b/src/core/components/push_payload.js @@ -1,6 +1,5 @@ /* */ /* eslint max-classes-per-file: ["error", 5] */ -import { APNS2Configuration, APNS2Target } from '../flow_interfaces'; class BaseNotificationPayload { _subtitle; diff --git a/src/core/components/reconnection_manager.js b/src/core/components/reconnection_manager.js index c188b3607..6d221bd01 100644 --- a/src/core/components/reconnection_manager.js +++ b/src/core/components/reconnection_manager.js @@ -1,5 +1,4 @@ import TimeEndpoint from '../endpoints/time'; -import { StatusAnnouncement } from '../flow_interfaces'; export default class { _reconnectionCallback; diff --git a/src/core/endpoints/access_manager/audit.js b/src/core/endpoints/access_manager/audit.js index ecae65af0..dcbab0a74 100644 --- a/src/core/endpoints/access_manager/audit.js +++ b/src/core/endpoints/access_manager/audit.js @@ -1,6 +1,5 @@ /* */ -import { AuditArguments, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; export function getOperation() { diff --git a/src/core/endpoints/access_manager/grant.js b/src/core/endpoints/access_manager/grant.js index a6ba5730a..9d63f84a8 100644 --- a/src/core/endpoints/access_manager/grant.js +++ b/src/core/endpoints/access_manager/grant.js @@ -1,6 +1,4 @@ /* */ - -import { GrantArguments, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; export function getOperation() { diff --git a/src/core/endpoints/actions/add_message_action.js b/src/core/endpoints/actions/add_message_action.js index 3aa4f49a4..e07ebb6cc 100644 --- a/src/core/endpoints/actions/add_message_action.js +++ b/src/core/endpoints/actions/add_message_action.js @@ -1,6 +1,5 @@ /* */ -import { AddMessageActionInput, AddMessageActionResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/actions/get_message_actions.js b/src/core/endpoints/actions/get_message_actions.js index 77a6471d5..ebe4fbb7d 100644 --- a/src/core/endpoints/actions/get_message_actions.js +++ b/src/core/endpoints/actions/get_message_actions.js @@ -1,6 +1,4 @@ /* */ - -import { GetMessageActionsInput, GetMessageActionsResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/actions/remove_message_action.js b/src/core/endpoints/actions/remove_message_action.js index 91bdd93a7..479cfb2e6 100644 --- a/src/core/endpoints/actions/remove_message_action.js +++ b/src/core/endpoints/actions/remove_message_action.js @@ -1,6 +1,5 @@ /* */ -import { RemoveMessageActionInput, RemoveMessageActionResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/channel_groups/add_channels.js b/src/core/endpoints/channel_groups/add_channels.js index 4e056a188..804decdf6 100644 --- a/src/core/endpoints/channel_groups/add_channels.js +++ b/src/core/endpoints/channel_groups/add_channels.js @@ -1,6 +1,4 @@ /* */ - -import { AddChannelParams, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/channel_groups/delete_group.js b/src/core/endpoints/channel_groups/delete_group.js index 8c815fc61..1dff624d6 100644 --- a/src/core/endpoints/channel_groups/delete_group.js +++ b/src/core/endpoints/channel_groups/delete_group.js @@ -1,6 +1,5 @@ /* */ -import { DeleteGroupParams, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/channel_groups/list_channels.js b/src/core/endpoints/channel_groups/list_channels.js index 9de4b03f2..245857d5e 100644 --- a/src/core/endpoints/channel_groups/list_channels.js +++ b/src/core/endpoints/channel_groups/list_channels.js @@ -1,6 +1,4 @@ /* */ - -import { ListChannelsParams, ListChannelsResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/channel_groups/list_groups.js b/src/core/endpoints/channel_groups/list_groups.js index ffe403838..8642f397f 100644 --- a/src/core/endpoints/channel_groups/list_groups.js +++ b/src/core/endpoints/channel_groups/list_groups.js @@ -1,6 +1,5 @@ /* */ -import { ListAllGroupsResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; export function getOperation() { diff --git a/src/core/endpoints/channel_groups/remove_channels.js b/src/core/endpoints/channel_groups/remove_channels.js index 868a7702e..54c664f55 100644 --- a/src/core/endpoints/channel_groups/remove_channels.js +++ b/src/core/endpoints/channel_groups/remove_channels.js @@ -1,6 +1,4 @@ /* */ - -import { RemoveChannelParams, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/fetch_messages.js b/src/core/endpoints/fetch_messages.js index 2e4fca70e..bb4c0d3be 100644 --- a/src/core/endpoints/fetch_messages.js +++ b/src/core/endpoints/fetch_messages.js @@ -1,12 +1,4 @@ /* */ - -import { - FetchMessagesArguments, - FetchMessagesResponse, - MessageAnnouncement, - HistoryV3Response, - ModulesInject, -} from '../flow_interfaces'; import operationConstants from '../constants/operations'; import utils from '../utils'; diff --git a/src/core/endpoints/history/delete_messages.js b/src/core/endpoints/history/delete_messages.js index be7a2b56c..aaf8b12d7 100644 --- a/src/core/endpoints/history/delete_messages.js +++ b/src/core/endpoints/history/delete_messages.js @@ -1,6 +1,5 @@ /* */ -import { FetchHistoryArguments, HistoryResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/history/get_history.js b/src/core/endpoints/history/get_history.js index 1b6ca15f6..bf76c52a2 100644 --- a/src/core/endpoints/history/get_history.js +++ b/src/core/endpoints/history/get_history.js @@ -1,6 +1,4 @@ /* */ - -import { FetchHistoryArguments, HistoryResponse, HistoryItem, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/presence/get_state.js b/src/core/endpoints/presence/get_state.js index bb0c81c62..c75caa82a 100644 --- a/src/core/endpoints/presence/get_state.js +++ b/src/core/endpoints/presence/get_state.js @@ -1,6 +1,5 @@ /* */ -import { GetStateArguments, GetStateResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/presence/heartbeat.js b/src/core/endpoints/presence/heartbeat.js index 293dea043..b5b0b7627 100644 --- a/src/core/endpoints/presence/heartbeat.js +++ b/src/core/endpoints/presence/heartbeat.js @@ -1,6 +1,5 @@ /* */ -import { HeartbeatArguments, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/presence/here_now.js b/src/core/endpoints/presence/here_now.js index 2f76e40bd..53d707c1e 100644 --- a/src/core/endpoints/presence/here_now.js +++ b/src/core/endpoints/presence/here_now.js @@ -1,6 +1,4 @@ /* */ - -import { HereNowArguments, ModulesInject, StatusAnnouncement } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/presence/leave.js b/src/core/endpoints/presence/leave.js index 54d5d3419..ed8962603 100644 --- a/src/core/endpoints/presence/leave.js +++ b/src/core/endpoints/presence/leave.js @@ -1,6 +1,5 @@ /* */ -import { LeaveArguments, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/presence/where_now.js b/src/core/endpoints/presence/where_now.js index b1c47bdbc..bc6daeb93 100644 --- a/src/core/endpoints/presence/where_now.js +++ b/src/core/endpoints/presence/where_now.js @@ -1,6 +1,4 @@ /* */ - -import { WhereNowArguments, WhereNowResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; import utils from '../../utils'; diff --git a/src/core/endpoints/publish.js b/src/core/endpoints/publish.js index 2cb90f0e8..5fddd7d21 100644 --- a/src/core/endpoints/publish.js +++ b/src/core/endpoints/publish.js @@ -1,6 +1,4 @@ /* */ - -import { PublishResponse, PublishArguments, ModulesInject } from '../flow_interfaces'; import operationConstants from '../constants/operations'; import utils from '../utils'; import { encode } from '../components/base64_codec'; diff --git a/src/core/endpoints/push/add_push_channels.js b/src/core/endpoints/push/add_push_channels.js index 159b0ec77..759a8ce63 100644 --- a/src/core/endpoints/push/add_push_channels.js +++ b/src/core/endpoints/push/add_push_channels.js @@ -1,6 +1,5 @@ /* */ -import { ModifyDeviceArgs, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; export function getOperation() { diff --git a/src/core/endpoints/push/list_push_channels.js b/src/core/endpoints/push/list_push_channels.js index 4345d3e49..25e6fc347 100644 --- a/src/core/endpoints/push/list_push_channels.js +++ b/src/core/endpoints/push/list_push_channels.js @@ -1,6 +1,4 @@ /* */ - -import { ListChannelsArgs, ListChannelsResponse, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; export function getOperation() { diff --git a/src/core/endpoints/push/remove_device.js b/src/core/endpoints/push/remove_device.js index 69877ab94..1f1d350fb 100644 --- a/src/core/endpoints/push/remove_device.js +++ b/src/core/endpoints/push/remove_device.js @@ -1,6 +1,5 @@ /* */ -import { RemoveDeviceArgs, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; export function getOperation() { diff --git a/src/core/endpoints/push/remove_push_channels.js b/src/core/endpoints/push/remove_push_channels.js index 322287c2f..16cc9bcfd 100644 --- a/src/core/endpoints/push/remove_push_channels.js +++ b/src/core/endpoints/push/remove_push_channels.js @@ -1,6 +1,5 @@ /* */ -import { ModifyDeviceArgs, ModulesInject } from '../../flow_interfaces'; import operationConstants from '../../constants/operations'; export function getOperation() { diff --git a/src/core/endpoints/signal.js b/src/core/endpoints/signal.js index aefa15085..ff7aa4802 100644 --- a/src/core/endpoints/signal.js +++ b/src/core/endpoints/signal.js @@ -1,6 +1,5 @@ /* */ -import { SignalResponse, SignalArguments, ModulesInject } from '../flow_interfaces'; import operationConstants from '../constants/operations'; import utils from '../utils'; diff --git a/src/core/endpoints/subscribe.js b/src/core/endpoints/subscribe.js index 46e0a7e8e..faf6d1306 100644 --- a/src/core/endpoints/subscribe.js +++ b/src/core/endpoints/subscribe.js @@ -1,13 +1,4 @@ /* */ - -import { - SubscribeArguments, - PublishMetaData, - SubscribeMetadata, - SubscribeMessage, - SubscribeEnvelope, - ModulesInject, -} from '../flow_interfaces'; import operationConstants from '../constants/operations'; import utils from '../utils'; diff --git a/src/core/endpoints/time.js b/src/core/endpoints/time.js index b5ab76ca1..f5996c0e4 100644 --- a/src/core/endpoints/time.js +++ b/src/core/endpoints/time.js @@ -1,6 +1,4 @@ /* */ - -import { TimeResponse, ModulesInject } from '../flow_interfaces'; import operationConstants from '../constants/operations'; export function getOperation() { diff --git a/src/nativescript/index.js b/src/nativescript/index.js index f7cf6a141..0a9def174 100644 --- a/src/nativescript/index.js +++ b/src/nativescript/index.js @@ -4,7 +4,6 @@ import PubNubCore from '../core/pubnub-common'; import Networking from '../networking'; import Database from '../db/common'; import { del, get, post, patch } from '../networking/modules/nativescript'; -import { InternalSetupStruct } from '../core/flow_interfaces'; export default class extends PubNubCore { constructor(setup) { diff --git a/src/networking/index.js b/src/networking/index.js index 58ca49289..74d666294 100644 --- a/src/networking/index.js +++ b/src/networking/index.js @@ -3,8 +3,6 @@ import Config from '../core/components/config'; import categoryConstants from '../core/constants/categories'; -import { EndpointDefinition, NetworkingModules } from '../core/flow_interfaces'; - export default class { _modules; diff --git a/src/networking/modules/nativescript.js b/src/networking/modules/nativescript.js index 22c08e499..b86fe7719 100644 --- a/src/networking/modules/nativescript.js +++ b/src/networking/modules/nativescript.js @@ -1,7 +1,6 @@ /* */ import { request as HttpRequest } from 'http'; -import { EndpointDefinition, StatusAnnouncement } from '../../core/flow_interfaces'; import { buildUrl } from '../utils'; function log(url, qs, res) { diff --git a/src/networking/modules/titanium.js b/src/networking/modules/titanium.js index f4d04d703..af496373d 100644 --- a/src/networking/modules/titanium.js +++ b/src/networking/modules/titanium.js @@ -1,7 +1,6 @@ /* */ /* global XMLHttpRequest, Ti */ -import { EndpointDefinition, StatusAnnouncement } from '../../core/flow_interfaces'; import { buildUrl } from '../utils'; function log(url, qs, res) { From e93db098006ade77b7091b8e56a42133fee6951f Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Tue, 16 Jan 2024 03:04:35 +0000 Subject: [PATCH 63/63] PubNub SDK v7.5.0 release. --- .pubnub.yml | 15 ++++++++++++--- CHANGELOG.md | 10 ++++++++++ README.md | 4 ++-- dist/web/pubnub.js | 5 ++--- dist/web/pubnub.min.js | 2 +- lib/core/components/config.js | 2 +- lib/core/components/push_payload.js | 2 ++ lib/core/endpoints/access_manager/grant.js | 2 +- lib/core/endpoints/actions/get_message_actions.js | 2 +- lib/core/endpoints/channel_groups/add_channels.js | 2 +- .../endpoints/channel_groups/list_channels.js | 2 +- .../endpoints/channel_groups/remove_channels.js | 2 +- lib/core/endpoints/fetch_messages.js | 2 +- lib/core/endpoints/history/get_history.js | 2 +- lib/core/endpoints/presence/here_now.js | 2 +- lib/core/endpoints/presence/where_now.js | 2 +- lib/core/endpoints/publish.js | 2 +- lib/core/endpoints/push/list_push_channels.js | 2 +- lib/core/endpoints/subscribe.js | 2 +- lib/core/endpoints/time.js | 2 +- package.json | 2 +- src/core/components/config.js | 2 +- 22 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index eb4701846..c9d019e0a 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,5 +1,14 @@ --- changelog: + - date: 2024-01-16 + version: v7.5.0 + changes: + - type: feature + text: "Added `enableEventEngine`, `maintainPresenceState` flags and `retryConfiguration` for retry policy configuration." + - type: bug + text: "Fixes issue of allowing duplicate listener registration." + - type: bug + text: "Fixes file name conflict in lib directory." - date: 2023-11-28 version: v7.4.5 changes: @@ -929,7 +938,7 @@ supported-platforms: - 'Ubuntu 14.04 and up' - 'Windows 7 and up' version: 'Pubnub Javascript for Node' -version: '7.4.5' +version: '7.5.0' sdks: - full-name: PubNub Javascript SDK short-name: Javascript @@ -945,7 +954,7 @@ sdks: - distribution-type: source distribution-repository: GitHub release package-name: pubnub.js - location: https://github.com/pubnub/javascript/archive/refs/tags/v7.4.5.zip + location: https://github.com/pubnub/javascript/archive/refs/tags/v7.5.0.zip requires: - name: 'agentkeepalive' min-version: '3.5.2' @@ -1616,7 +1625,7 @@ sdks: - distribution-type: library distribution-repository: GitHub release package-name: pubnub.js - location: https://github.com/pubnub/javascript/releases/download/v7.4.5/pubnub.7.4.5.js + location: https://github.com/pubnub/javascript/releases/download/v7.5.0/pubnub.7.5.0.js requires: - name: 'agentkeepalive' min-version: '3.5.2' diff --git a/CHANGELOG.md b/CHANGELOG.md index 0adfe22b3..cdce7699f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v7.5.0 +January 16 2024 + +#### Added +- Added `enableEventEngine`, `maintainPresenceState` flags and `retryConfiguration` for retry policy configuration. + +#### Fixed +- Fixes issue of allowing duplicate listener registration. +- Fixes file name conflict in lib directory. Fixed the following issues reported by [@priyanshu102002](https://github.com/priyanshu102002): [#355](https://github.com/pubnub/javascript/issues/355). + ## v7.4.5 November 28 2023 diff --git a/README.md b/README.md index fbfbd3864..1dc2eb8d9 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2 npm install pubnub ``` * or download one of our builds from our CDN: - * https://cdn.pubnub.com/sdk/javascript/pubnub.7.4.5.js - * https://cdn.pubnub.com/sdk/javascript/pubnub.7.4.5.min.js + * https://cdn.pubnub.com/sdk/javascript/pubnub.7.5.0.js + * https://cdn.pubnub.com/sdk/javascript/pubnub.7.5.0.min.js 2. Configure your keys: diff --git a/dist/web/pubnub.js b/dist/web/pubnub.js index c2c7bc49e..1c0eca8fc 100644 --- a/dist/web/pubnub.js +++ b/dist/web/pubnub.js @@ -794,7 +794,7 @@ return this; }; default_1.prototype.getVersion = function () { - return '7.4.5'; + return '7.5.0'; }; default_1.prototype._setRetryConfiguration = function (configuration) { if (configuration.minimumdelay < 2) { @@ -2665,6 +2665,7 @@ return default_1; }()); + /* */ var BaseNotificationPayload = /** @class */ (function () { function BaseNotificationPayload(payload, title, body) { this._payload = payload; @@ -4014,7 +4015,6 @@ handleResponse: handleResponse$m }); - /* */ function getOperation$l() { return OPERATIONS.PNPushNotificationEnabledChannelsOperation; } @@ -4367,7 +4367,6 @@ handleResponse: handleResponse$f }); - /* */ function getOperation$e() { return OPERATIONS.PNHereNowOperation; } diff --git a/dist/web/pubnub.min.js b/dist/web/pubnub.min.js index cda6dd5c1..bc8818dc5 100644 --- a/dist/web/pubnub.min.js +++ b/dist/web/pubnub.min.js @@ -14,4 +14,4 @@ PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o>2,c=0;c>6),o.push(128|63&a)):a<55296?(o.push(224|a>>12),o.push(128|a>>6&63),o.push(128|63&a)):(a=(1023&a)<<10,a|=1023&t.charCodeAt(++r),a+=65536,o.push(240|a>>18),o.push(128|a>>12&63),o.push(128|a>>6&63),o.push(128|63&a))}return h(3,o.length),p(o);default:var f;if(Array.isArray(t))for(h(4,f=t.length),r=0;r>5!==e)throw"Invalid indefinite length element";return n}function g(e,t){for(var n=0;n>10),e.push(56320|1023&r))}}"function"!=typeof t&&(t=function(e){return e}),"function"!=typeof i&&(i=function(){return n});var m=function e(){var o,h,m=l(),v=m>>5,b=31&m;if(7===v)switch(b){case 25:return function(){var e=new ArrayBuffer(4),t=new DataView(e),n=p(),o=32768&n,i=31744&n,a=1023&n;if(31744===i)i=261120;else if(0!==i)i+=114688;else if(0!==a)return a*r;return t.setUint32(0,o<<16|i<<13|a<<13),t.getFloat32(0)}();case 26:return u(a.getFloat32(s),4);case 27:return u(a.getFloat64(s),8)}if((h=d(b))<0&&(v<2||6=0;)S+=h,_.push(c(h));var w=new Uint8Array(S),O=0;for(o=0;o<_.length;++o)w.set(_[o],O),O+=_[o].length;return w}return c(h);case 3:var P=[];if(h<0)for(;(h=y(v))>=0;)g(P,h);else g(P,h);return String.fromCharCode.apply(null,P);case 4:var E;if(h<0)for(E=[];!f();)E.push(e());else for(E=new Array(h),o=0;o=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.4.5"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=h,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],h=e[i+4],f=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,h,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,h,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,h,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,h,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=f[y],b=f[v],_=f[b],S=257*f[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,h[m]=S,y?(y=v^f[f[f[_^v]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^h[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,h,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&h]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[h>>>8&255]^a[255&c]^n[f++],m=r[p>>>24]^o[h>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];h=r[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&h])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^n[f++],m=(s[p>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,h=i.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,d=s.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,h=e.file,f=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,C,k,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!h)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(h),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&h.uri?(A=(T=p).POSTFILE,C=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=h?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,h=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,h=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||d||h||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:h,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Mt.on(Ct.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(kt.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(Ct.type,(function(e,t){return Ft.with(n(n({},e),{cursor:t.payload.cursor||e.cursor}))})),jt.on(gt.type,(function(e,t){var n;return jt.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?void 0:n.region)||0}})})),jt.on(kt.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(kt.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(kt.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),It.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ht({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null===(n=t.payload.cursor)||void 0===n?void 0:n.region)||(null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.region)||0}})})),Dt.on(kt.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ht({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n;return Ft.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?void 0:n.region)||0}})})),Ft.on(kt.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(Ct(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},e.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:this.delay)+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var h=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(h=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=h.message,a.file={id:h.file.id,name:h.file.name,url:this.getFileUrl({id:h.file.id,name:h.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var d;f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var h=new I({maximumSamplesCount:6e4});this._telemetryManager=h;var f=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,he),this.removeMessageAction=Q.bind(this,d,fe),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function Cn(e,t,n,r){void 0===r&&(r=On());var o,i=kn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function kn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var fr=pr,dr=hr.exports,yr=dr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Cr=Boolean.prototype.valueOf,kr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return kr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Fr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function fo(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=fo(t,f);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=fo(t,f);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,h)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=fo(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,h)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,h)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(Cr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=fo(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":h?C+"{"+ho(P,h)+"}":C+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},Co=String.prototype.replace,ko=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return Co.call(e,ko,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+h:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,h.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:Ci,post:ki,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(h.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(hn);return Bi})); +!function(e,t){!function(e){var t="0.1.0",n={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 r(){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 o(e,t){var r=n[t||"all"];return r&&r.test(e)||!1}r.isUUID=o,r.VERSION=t,e.uuid=r,e.isUUID=o}(t),null!==e&&(e.exports=t.uuid)}(f,f.exports);var d=f.exports,y=function(){return d.uuid?d.uuid():d()},g=function(){function e(e){var t,n,r,o,i=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(y()),this.secretKey=i.secretKey||i.secret_key,this.subscribeKey=i.subscribeKey||i.subscribe_key,this.publishKey=i.publishKey||i.publish_key,this.sdkName=i.sdkName,this.sdkFamily=i.sdkFamily,this.partnerId=i.partnerId,this.setAuthKey(i.authKey),this.cryptoModule=i.cryptoModule,this.setFilterExpression(i.filterExpression),"string"!=typeof i.origin&&!Array.isArray(i.origin)&&void 0!==i.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=i.origin||Array.from({length:20},(function(e,t){return"ps".concat(t+1,".pndsn.com")})),this.secure=i.ssl||!1,this.restore=i.restore||!1,this.proxy=i.proxy,this.keepAlive=i.keepAlive,this.keepAliveSettings=i.keepAliveSettings,this.autoNetworkDetection=i.autoNetworkDetection||!1,this.dedupeOnSubscribe=i.dedupeOnSubscribe||!1,this.maximumCacheSize=i.maximumCacheSize||100,this.customEncrypt=i.customEncrypt,this.customDecrypt=i.customDecrypt,this.fileUploadPublishRetryLimit=null!==(t=i.fileUploadPublishRetryLimit)&&void 0!==t?t:5,this.useRandomIVs=null===(n=i.useRandomIVs)||void 0===n||n,this.enableEventEngine=null!==(r=i.enableEventEngine)&&void 0!==r&&r,this.maintainPresenceState=null===(o=i.maintainPresenceState)||void 0===o||o,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=i.logVerbosity||!1,this.suppressLeaveEvents=i.suppressLeaveEvents||!1,this.announceFailedHeartbeats=i.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=i.announceSuccessfulHeartbeats||!1,this.useInstanceId=i.useInstanceId||!1,this.useRequestId=i.useRequestId||!1,this.requestMessageCountThreshold=i.requestMessageCountThreshold,i.retryConfiguration&&this._setRetryConfiguration(i.retryConfiguration),this.setTransactionTimeout(i.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(i.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(i.useSendBeacon||!0),i.presenceTimeout?this.setPresenceTimeout(i.presenceTimeout):this._presenceTimeout=300,null!=i.heartbeatInterval&&this.setHeartbeatInterval(i.heartbeatInterval),"string"==typeof i.userId){if("string"==typeof i.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(i.userId)}else{if("string"!=typeof i.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(i.uuid)}this.setCipherKey(i.cipherKey,i)}return e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,n){var r;return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!==(r=t.cryptoModule)&&void 0!==r?r:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),n&&(n.cryptoModule=this.cryptoModule)),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=e,this},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(!e||"string"!=typeof e||0===e.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=e,this},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return e>=20?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.5.0"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(e.maximumDelay>150)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&maximumRetry>6)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(e.maximumRetry>10)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(e){var t=this;return Object.keys(this._PNSDKSuffix).reduce((function(n,r){return n+e+t._PNSDKSuffix[r]}),"")},e}();function m(e){var t=e.replace(/==?$/,""),n=Math.floor(t.length/4*3),r=new ArrayBuffer(n),o=new Uint8Array(r),i=0;function a(){var e=t.charAt(i++),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===n)throw new Error("Illegal character at ".concat(i,": ").concat(t.charAt(i-1)));return n}for(var s=0;s>4,f=(15&c)<<4|l>>2,d=(3&l)<<6|p>>0;o[s]=h,64!=l&&(o[s+1]=f),64!=p&&(o[s+2]=d)}return r}function v(e){for(var t,n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),i=o.byteLength,a=i%3,s=i-a,u=0;u>18]+r[(258048&t)>>12]+r[(4032&t)>>6]+r[63&t];return 1==a?n+=r[(252&(t=o[s]))>>2]+r[(3&t)<<4]+"==":2==a&&(n+=r[(64512&(t=o[s]<<8|o[s+1]))>>10]+r[(1008&t)>>4]+r[(15&t)<<2]+"="),n}var b,_,S,w,O,P=P||function(e,t){var n={},r=n.lib={},o=function(){},i=r.Base={extend:function(e){o.prototype=this;var t=new o;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)}},a=r.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes;if(e=e.sigBytes,this.clamp(),r%4)for(var o=0;o>>2]|=(n[o>>>2]>>>24-o%4*8&255)<<24-(r+o)%4*8;else if(65535>>2]=n[o>>>2];else t.push.apply(t,n);return this.sigBytes+=e,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n=[],r=0;r>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new a.init(n,t/2)}},c=s.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var n=[],r=0;r>>2]>>>24-r%4*8&255));return n.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new a.init(n,t)}},l=s.Utf8={stringify:function(e){try{return decodeURIComponent(escape(c.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return c.parse(unescape(encodeURIComponent(e)))}},p=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,s=o/(4*i);if(t=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*i,o=e.min(4*t,o),t){for(var u=0;uc;){var l;e:{l=u;for(var p=e.sqrt(l),h=2;h<=p;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>c&&(i[c]=s(e.pow(u,.5))),a[c]=s(e.pow(u,1/3)),c++),u++}var f=[];o=o.SHA256=r.extend({_doReset:function(){this._hash=new n.init(i.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],u=n[4],c=n[5],l=n[6],p=n[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var d=f[h-15],y=f[h-2];f[h]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+f[h-7]+((y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10)+f[h-16]}d=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&l)+a[h]+f[h],y=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&o^r&i^o&i),p=l,l=c,c=u,u=s+d|0,s=i,i=o,o=r,r=d+y|0}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+u|0,n[5]=n[5]+c|0,n[6]=n[6]+l|0,n[7]=n[7]+p|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;return n[o>>>5]|=128<<24-o%32,n[14+(o+64>>>9<<4)]=e.floor(r/4294967296),n[15+(o+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=r._createHelper(o),t.HmacSHA256=r._createHmacHelper(o)}(Math),_=(b=P).enc.Utf8,b.algo.HMAC=b.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=_.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,s=i.words,u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;4>a&&o+.75*a>>6*(3-a)&63));if(t=r.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,n=this._map;(r=n.charAt(64))&&-1!=(r=e.indexOf(r))&&(t=r);for(var r=[],o=0,i=0;i>>6-i%4*2;r[o>>>2]|=(a|s)<<24-o%4*8,o++}return w.create(r,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(e){function t(e,t,n,r,o,i,a){return((e=e+(t&n|~t&r)+o+a)<>>32-i)+t}function n(e,t,n,r,o,i,a){return((e=e+(t&r|n&~r)+o+a)<>>32-i)+t}function r(e,t,n,r,o,i,a){return((e=e+(t^n^r)+o+a)<>>32-i)+t}function o(e,t,n,r,o,i,a){return((e=e+(n^(t|~r))+o+a)<>>32-i)+t}for(var i=P,a=(u=i.lib).WordArray,s=u.Hasher,u=i.algo,c=[],l=0;64>l;l++)c[l]=4294967296*e.abs(e.sin(l+1))|0;u=u.MD5=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,i){for(var a=0;16>a;a++){var s=e[u=i+a];e[u]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}a=this._hash.words;var u=e[i+0],l=(s=e[i+1],e[i+2]),p=e[i+3],h=e[i+4],f=e[i+5],d=e[i+6],y=e[i+7],g=e[i+8],m=e[i+9],v=e[i+10],b=e[i+11],_=e[i+12],S=e[i+13],w=e[i+14],O=e[i+15],P=t(P=a[0],A=a[1],T=a[2],E=a[3],u,7,c[0]),E=t(E,P,A,T,s,12,c[1]),T=t(T,E,P,A,l,17,c[2]),A=t(A,T,E,P,p,22,c[3]);P=t(P,A,T,E,h,7,c[4]),E=t(E,P,A,T,f,12,c[5]),T=t(T,E,P,A,d,17,c[6]),A=t(A,T,E,P,y,22,c[7]),P=t(P,A,T,E,g,7,c[8]),E=t(E,P,A,T,m,12,c[9]),T=t(T,E,P,A,v,17,c[10]),A=t(A,T,E,P,b,22,c[11]),P=t(P,A,T,E,_,7,c[12]),E=t(E,P,A,T,S,12,c[13]),T=t(T,E,P,A,w,17,c[14]),P=n(P,A=t(A,T,E,P,O,22,c[15]),T,E,s,5,c[16]),E=n(E,P,A,T,d,9,c[17]),T=n(T,E,P,A,b,14,c[18]),A=n(A,T,E,P,u,20,c[19]),P=n(P,A,T,E,f,5,c[20]),E=n(E,P,A,T,v,9,c[21]),T=n(T,E,P,A,O,14,c[22]),A=n(A,T,E,P,h,20,c[23]),P=n(P,A,T,E,m,5,c[24]),E=n(E,P,A,T,w,9,c[25]),T=n(T,E,P,A,p,14,c[26]),A=n(A,T,E,P,g,20,c[27]),P=n(P,A,T,E,S,5,c[28]),E=n(E,P,A,T,l,9,c[29]),T=n(T,E,P,A,y,14,c[30]),P=r(P,A=n(A,T,E,P,_,20,c[31]),T,E,f,4,c[32]),E=r(E,P,A,T,g,11,c[33]),T=r(T,E,P,A,b,16,c[34]),A=r(A,T,E,P,w,23,c[35]),P=r(P,A,T,E,s,4,c[36]),E=r(E,P,A,T,h,11,c[37]),T=r(T,E,P,A,y,16,c[38]),A=r(A,T,E,P,v,23,c[39]),P=r(P,A,T,E,S,4,c[40]),E=r(E,P,A,T,u,11,c[41]),T=r(T,E,P,A,p,16,c[42]),A=r(A,T,E,P,d,23,c[43]),P=r(P,A,T,E,m,4,c[44]),E=r(E,P,A,T,_,11,c[45]),T=r(T,E,P,A,O,16,c[46]),P=o(P,A=r(A,T,E,P,l,23,c[47]),T,E,u,6,c[48]),E=o(E,P,A,T,y,10,c[49]),T=o(T,E,P,A,w,15,c[50]),A=o(A,T,E,P,f,21,c[51]),P=o(P,A,T,E,_,6,c[52]),E=o(E,P,A,T,p,10,c[53]),T=o(T,E,P,A,v,15,c[54]),A=o(A,T,E,P,s,21,c[55]),P=o(P,A,T,E,g,6,c[56]),E=o(E,P,A,T,O,10,c[57]),T=o(T,E,P,A,d,15,c[58]),A=o(A,T,E,P,S,21,c[59]),P=o(P,A,T,E,h,6,c[60]),E=o(E,P,A,T,b,10,c[61]),T=o(T,E,P,A,l,15,c[62]),A=o(A,T,E,P,m,21,c[63]);a[0]=a[0]+P|0,a[1]=a[1]+A|0,a[2]=a[2]+T|0,a[3]=a[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296);for(n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(n.length+1),this._process(),n=(t=this._hash).words,r=0;4>r;r++)o=n[r],n[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8);return t},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),i.MD5=s._createHelper(u),i.HmacMD5=s._createHmacHelper(u)}(Math),function(){var e,t=P,n=(e=t.lib).Base,r=e.WordArray,o=(e=t.algo).EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:e.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=(s=this.cfg).hasher.create(),o=r.create(),i=o.words,a=s.keySize,s=s.iterations;i.length>>2]}},t.BlockCipher=s.extend({cfg:s.cfg.extend({mode:u,padding:l}),reset:function(){s.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});var p=t.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),h=(u=(f.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?r.create([1398893684,1701076831]).concat(e).concat(t):t).toString(i)},parse:function(e){var t=(e=i.parse(e)).words;if(1398893684==t[0]&&1701076831==t[1]){var n=r.create(t.slice(2,4));t.splice(0,4),e.sigBytes-=16}return p.create({ciphertext:e,salt:n})}},t.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var o=e.createEncryptor(n,r);return t=o.finalize(t),o=o.cfg,p.create({ciphertext:t,key:n,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}})),f=(f.kdf={}).OpenSSL={execute:function(e,t,n,o){return o||(o=r.random(8)),e=a.create({keySize:t+n}).compute(e,o),n=r.create(e.words.slice(t),4*n),e.sigBytes=4*t,p.create({key:e,iv:n,salt:o})}},d=t.PasswordBasedCipher=h.extend({cfg:h.cfg.extend({kdf:f}),encrypt:function(e,t,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize),r.iv=n.iv,(e=h.encrypt.call(this,e,t,n.key,r)).mixIn(n),e},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),n=r.kdf.execute(n,e.keySize,e.ivSize,t.salt),r.iv=n.iv,h.decrypt.call(this,e,t,n.key,r)}})}(),function(){for(var e=P,t=e.lib.BlockCipher,n=e.algo,r=[],o=[],i=[],a=[],s=[],u=[],c=[],l=[],p=[],h=[],f=[],d=0;256>d;d++)f[d]=128>d?d<<1:d<<1^283;var y=0,g=0;for(d=0;256>d;d++){var m=(m=g^g<<1^g<<2^g<<3^g<<4)>>>8^255&m^99;r[y]=m,o[m]=y;var v=f[y],b=f[v],_=f[b],S=257*f[m]^16843008*m;i[y]=S<<24|S>>>8,a[y]=S<<16|S>>>16,s[y]=S<<8|S>>>24,u[y]=S,S=16843009*_^65537*b^257*v^16843008*y,c[m]=S<<24|S>>>8,l[m]=S<<16|S>>>16,p[m]=S<<8|S>>>24,h[m]=S,y?(y=v^f[f[f[_^v]]],g^=f[f[g]]):y=g=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=t.extend({_doReset:function(){for(var e=(n=this._key).words,t=n.sigBytes/4,n=4*((this._nRounds=t+6)+1),o=this._keySchedule=[],i=0;i>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[i/t|0]<<24),o[i]=o[i-t]^a}for(e=this._invKeySchedule=[],t=0;tt||4>=i?a:c[r[a>>>24]]^l[r[a>>>16&255]]^p[r[a>>>8&255]]^h[r[255&a]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,i,a,s,u,r)},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,c,l,p,h,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,o,i,a,s){for(var u=this._nRounds,c=e[t]^n[0],l=e[t+1]^n[1],p=e[t+2]^n[2],h=e[t+3]^n[3],f=4,d=1;d>>24]^o[l>>>16&255]^i[p>>>8&255]^a[255&h]^n[f++],g=r[l>>>24]^o[p>>>16&255]^i[h>>>8&255]^a[255&c]^n[f++],m=r[p>>>24]^o[h>>>16&255]^i[c>>>8&255]^a[255&l]^n[f++];h=r[h>>>24]^o[c>>>16&255]^i[l>>>8&255]^a[255&p]^n[f++],c=y,l=g,p=m}y=(s[c>>>24]<<24|s[l>>>16&255]<<16|s[p>>>8&255]<<8|s[255&h])^n[f++],g=(s[l>>>24]<<24|s[p>>>16&255]<<16|s[h>>>8&255]<<8|s[255&c])^n[f++],m=(s[p>>>24]<<24|s[h>>>16&255]<<16|s[c>>>8&255]<<8|s[255&l])^n[f++],h=(s[h>>>24]<<24|s[c>>>16&255]<<16|s[l>>>8&255]<<8|s[255&p])^n[f++],e[t]=y,e[t+1]=g,e[t+2]=m,e[t+3]=h},keySize:8});e.AES=t._createHelper(n)}(),P.mode.ECB=((O=P.lib.BlockCipherMode.extend()).Encryptor=O.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),O.Decryptor=O.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),O);var E=P;function T(e){var t,n=[];for(t=0;t=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},e.prototype.clearHistory=function(){this.hashHistory=[]},e}();function N(e){return encodeURIComponent(e).replace(/[!~*'()]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())}))}function M(e){return function(e){var t=[];return Object.keys(e).forEach((function(e){return t.push(e)})),t}(e).sort()}var j={signPamFromParams:function(e){return M(e).map((function(t){return"".concat(t,"=").concat(N(e[t]))})).join("&")},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),reject:t,fulfill:e}},encodeString:N,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,o=e.length;r=u){var l={};l.category=R.PNRequestMessageCountExceededCategory,l.operation=e.operation,this._listenerManager.announceStatus(l)}a.forEach((function(e){var t=e.channel,i=e.subscriptionMatch,a=e.publishMetaData;if(t===i&&(i=null),c){if(o._dedupingManager.isDuplicate(e))return;o._dedupingManager.addEntry(e)}if(j.endsWith(e.channel,"-pnpres"))(y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,t&&(y.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(y.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),y.action=e.payload.action,y.state=e.payload.data,y.timetoken=a.publishTimetoken,y.occupancy=e.payload.occupancy,y.uuid=e.payload.uuid,y.timestamp=e.payload.timestamp,e.payload.join&&(y.join=e.payload.join),e.payload.leave&&(y.leave=e.payload.leave),e.payload.timeout&&(y.timeout=e.payload.timeout),o._listenerManager.announcePresence(y);else if(1===e.messageType){(y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=e.payload,o._listenerManager.announceSignal(y)}else if(2===e.messageType){if((y={channel:null,subscription:null}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),y.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},o._listenerManager.announceObjects(y),"uuid"===e.payload.type){var s=o._renameChannelField(y);o._listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"user"})}))}else if("channel"===e.payload.type){s=o._renameChannelField(y);o._listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),type:"space"})}))}else if("membership"===e.payload.type){var u=(s=o._renameChannelField(y)).message.data,l=u.uuid,p=u.channel,h=r(u,["uuid","channel"]);h.user=l,h.space=p,o._listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:o._renameEvent(s.message.event),data:h})}))}}else if(3===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,y.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},y.event=e.payload.event,o._listenerManager.announceMessageAction(y)}else if(4===e.messageType){(y={}).channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId;var f=e.payload;if(o._cryptoModule){var d=void 0;try{d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}null!==d&&(f=d)}e.userMetadata&&(y.userMetadata=e.userMetadata),y.message=f.message,y.file={id:f.file.id,name:f.file.name,url:o._getFileUrl({id:f.file.id,name:f.file.name,channel:t})},o._listenerManager.announceFile(y)}else{var y;if((y={channel:null,subscription:null}).actualChannel=null!=i?t:null,y.subscribedChannel=null!=i?i:t,y.channel=t,y.subscription=i,y.timetoken=a.publishTimetoken,y.publisher=e.issuingClientId,e.userMetadata&&(y.userMetadata=e.userMetadata),o._cryptoModule){d=void 0;try{var g;d=(g=o._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(o._decoder.decode(g)):g}catch(e){d=null,y.error="Error while decrypting message content: ".concat(e.message)}y.message=null!=d?d:e.payload}else y.message=e.payload;o._listenerManager.announceMessage(y)}})),this._region=t.metadata.region,this._startSubscribeLoop()}},e.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),U={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},I=function(){function e(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}return e.prototype.operationsLatencyForRequest=function(){var e=this,t={};return Object.keys(this._latencies).forEach((function(n){var r=e._latencies[n],o=e._averageLatency(r);o>0&&(t["l_".concat(n)]=o)})),t},e.prototype.startLatencyMeasure=function(e,t){e!==U.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},e.prototype.stopLatencyMeasure=function(e,t){if(e!==U.PNSubscribeOperation&&t){var n=this._endpointName(e),r=this._latencies[n],o=this._trackedLatencies[t];r||(this._latencies[n]=[],r=this._latencies[n]),r.push(Date.now()-o),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t]}},e.prototype._averageLatency=function(e){return Math.floor(e.reduce((function(e,t){return e+t}),0)/e.length)},e.prototype._endpointName=function(e){var t=null;switch(e){case U.PNPublishOperation:t="pub";break;case U.PNSignalOperation:t="sig";break;case U.PNHistoryOperation:case U.PNFetchMessagesOperation:case U.PNDeleteMessagesOperation:case U.PNMessageCounts:t="hist";break;case U.PNUnsubscribeOperation:case U.PNWhereNowOperation:case U.PNHereNowOperation:case U.PNHeartbeatOperation:case U.PNSetStateOperation:case U.PNGetStateOperation:t="pres";break;case U.PNAddChannelsToGroupOperation:case U.PNRemoveChannelsFromGroupOperation:case U.PNChannelGroupsOperation:case U.PNRemoveGroupOperation:case U.PNChannelsForGroupOperation:t="cg";break;case U.PNPushNotificationEnabledChannelsOperation:case U.PNRemoveAllPushNotificationsOperation:t="push";break;case U.PNCreateUserOperation:case U.PNUpdateUserOperation:case U.PNDeleteUserOperation:case U.PNGetUserOperation:case U.PNGetUsersOperation:case U.PNCreateSpaceOperation:case U.PNUpdateSpaceOperation:case U.PNDeleteSpaceOperation:case U.PNGetSpaceOperation:case U.PNGetSpacesOperation:case U.PNGetMembersOperation:case U.PNUpdateMembersOperation:case U.PNGetMembershipsOperation:case U.PNUpdateMembershipsOperation:t="obj";break;case U.PNAddMessageActionOperation:case U.PNRemoveMessageActionOperation:case U.PNGetMessageActionsOperation:t="msga";break;case U.PNAccessManagerGrant:case U.PNAccessManagerAudit:t="pam";break;case U.PNAccessManagerGrantToken:case U.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},e}(),D=function(){function e(e,t,n){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=n}return Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),e.prototype._setDefaultPayloadStructure=function(){},e.prototype.toObject=function(){return{}},e}(),F=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),r.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},r.prototype.toObject=function(){var e=this,t=n({},this._payload),r=t.aps,o=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var i=[];this._configurations.forEach((function(t){i.push(e._objectFromAPNS2Configuration(t))})),i.length&&(t.pn_push=i)}return o&&Object.keys(o).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,o={}),this._isSilent||Object.keys(o).length?t:null},r.prototype._objectFromAPNS2Configuration=function(e){var t=this;if(!e.targets||!e.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var n=[];e.targets.forEach((function(e){n.push(t._objectFromAPNSTarget(e))}));var r=e.collapseId,o=e.expirationDate,i={auth_method:"token",targets:n,version:"v2"};return r&&r.length&&(i.collapse_id=r),o&&(i.expiration=o.toISOString()),i},r.prototype._objectFromAPNSTarget=function(e){if(!e.topic||!e.topic.length)throw new TypeError("Target 'topic' undefined.");var t=e.topic,n=e.environment,r=void 0===n?"development":n,o=e.excludedDevices,i=void 0===o?[]:o,a={topic:t,environment:r};return i.length&&(a.excluded_devices=i),a},r}(D),G=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t(r,e),Object.defineProperty(r.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),r.prototype.toObject=function(){return Object.keys(this._payload).length?n({},this._payload):null},r}(D),L=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t(o,e),Object.defineProperty(o.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),o.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},o.prototype.toObject=function(){var e=n({},this._payload.data),t=null,o={};if(Object.keys(this._payload).length>2){var i=this._payload;i.notification,i.data;var a=r(i,["notification","data"]);e=n(n({},e),a)}return this._isSilent?e.notification=this._payload.notification:t=this._payload.notification,Object.keys(e).length&&(o.data=e),t&&Object.keys(t).length&&(o.notification=t),Object.keys(o).length?o:null},o}(D),K=function(){function e(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new F(this._payload.apns,e,t),this.mpns=new G(this._payload.mpns,e,t),this.fcm=new L(this._payload.fcm,e,t)}return Object.defineProperty(e.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),e.prototype.buildPayload=function(e){var t={};if(e.includes("apns")||e.includes("apns2")){this.apns._apnsPushType=e.includes("apns")?"apns":"apns2";var n=this.apns.toObject();n&&Object.keys(n).length&&(t.pn_apns=n)}if(e.includes("mpns")){var r=this.mpns.toObject();r&&Object.keys(r).length&&(t.pn_mpns=r)}if(e.includes("fcm")){var o=this.fcm.toObject();o&&Object.keys(o).length&&(t.pn_gcm=o)}return Object.keys(t).length&&this._debugging&&(t.pn_debug=!0),t},e}(),B=function(){function e(){this._listeners=[]}return e.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},e.prototype.removeListener=function(e){var t=[];this._listeners.forEach((function(n){n!==e&&t.push(n)})),this._listeners=t},e.prototype.removeAllListeners=function(){this._listeners=[]},e.prototype.announcePresence=function(e){this._listeners.forEach((function(t){t.presence&&t.presence(e)}))},e.prototype.announceStatus=function(e){this._listeners.forEach((function(t){t.status&&t.status(e)}))},e.prototype.announceMessage=function(e){this._listeners.forEach((function(t){t.message&&t.message(e)}))},e.prototype.announceSignal=function(e){this._listeners.forEach((function(t){t.signal&&t.signal(e)}))},e.prototype.announceMessageAction=function(e){this._listeners.forEach((function(t){t.messageAction&&t.messageAction(e)}))},e.prototype.announceFile=function(e){this._listeners.forEach((function(t){t.file&&t.file(e)}))},e.prototype.announceObjects=function(e){this._listeners.forEach((function(t){t.objects&&t.objects(e)}))},e.prototype.announceUser=function(e){this._listeners.forEach((function(t){t.user&&t.user(e)}))},e.prototype.announceSpace=function(e){this._listeners.forEach((function(t){t.space&&t.space(e)}))},e.prototype.announceMembership=function(e){this._listeners.forEach((function(t){t.membership&&t.membership(e)}))},e.prototype.announceNetworkUp=function(){var e={};e.category=R.PNNetworkUpCategory,this.announceStatus(e)},e.prototype.announceNetworkDown=function(){var e={};e.category=R.PNNetworkDownCategory,this.announceStatus(e)},e}(),H=function(){function e(e,t){this._config=e,this._cbor=t}return e.prototype.setToken=function(e){e&&e.length>0?this._token=e:this._token=void 0},e.prototype.getToken=function(){return this._token},e.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},e.prototype.parseToken=function(e){var t=this,n=this._cbor.decodeToken(e);if(void 0!==n){var r=n.res.uuid?Object.keys(n.res.uuid):[],o=Object.keys(n.res.chan),i=Object.keys(n.res.grp),a=n.pat.uuid?Object.keys(n.pat.uuid):[],s=Object.keys(n.pat.chan),u=Object.keys(n.pat.grp),c={version:n.v,timestamp:n.t,ttl:n.ttl,authorized_uuid:n.uuid},l=r.length>0,p=o.length>0,h=i.length>0;(l||p||h)&&(c.resources={},l&&(c.resources.uuids={},r.forEach((function(e){c.resources.uuids[e]=t.extractPermissions(n.res.uuid[e])}))),p&&(c.resources.channels={},o.forEach((function(e){c.resources.channels[e]=t.extractPermissions(n.res.chan[e])}))),h&&(c.resources.groups={},i.forEach((function(e){c.resources.groups[e]=t.extractPermissions(n.res.grp[e])}))));var f=a.length>0,d=s.length>0,y=u.length>0;return(f||d||y)&&(c.patterns={},f&&(c.patterns.uuids={},a.forEach((function(e){c.patterns.uuids[e]=t.extractPermissions(n.pat.uuid[e])}))),d&&(c.patterns.channels={},s.forEach((function(e){c.patterns.channels[e]=t.extractPermissions(n.pat.chan[e])}))),y&&(c.patterns.groups={},u.forEach((function(e){c.patterns.groups[e]=t.extractPermissions(n.pat.grp[e])})))),Object.keys(n.meta).length>0&&(c.meta=n.meta),c.signature=n.sig,c}},e}(),q=function(e){function n(t,n){var r=this.constructor,o=e.call(this,t)||this;return o.name=o.constructor.name,o.status=n,o.message=t,Object.setPrototypeOf(o,r.prototype),o}return t(n,e),n}(Error);function z(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}function V(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.usePatch&&e.usePatch(t,n)?e.patchURL(t,n):e.useGetFile&&e.useGetFile(t,n)?e.getFileURL(t,n):e.getURL(t,n)}function W(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-".concat(e.sdkFamily);e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion());var n=e._getPnsdkSuffix(" ");return n.length>0&&(t+=n),t}function J(e,t,n){return t.usePost&&t.usePost(e,n)?"POST":t.usePatch&&t.usePatch(e,n)?"PATCH":t.useDelete&&t.useDelete(e,n)?"DELETE":t.useGetFile&&t.useGetFile(e,n)?"GETFILE":"GET"}function $(e,t,n,r,o){var i=e.config,a=e.crypto,s=J(e,o,r);n.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,r)&&(s="GET"),"GETFILE"===s&&(s="GET");var u="".concat(s,"\n").concat(i.publishKey,"\n").concat(t,"\n").concat(j.signPamFromParams(n),"\n");if("POST"===s)u+="string"==typeof(c=o.postPayload(e,r))?c:JSON.stringify(c);else if("PATCH"===s){var c;u+="string"==typeof(c=o.patchPayload(e,r))?c:JSON.stringify(c)}var l="v2.".concat(a.HMACSHA256(u));l=(l=(l=l.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),n.signature=l}function Q(e,t){for(var r=[],o=2;o0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(){return{}}});var se=Object.freeze({__proto__:null,getOperation:function(){return U.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r;return"/v2/presence/sub-key/".concat(n.subscribeKey,"/uuid/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}});var ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o=t.state,i=e.config,a={};return r.length>0&&(a["channel-group"]=r.join(",")),o&&(a.state=JSON.stringify(o)),a.heartbeat=i.getPresenceTimeout(),a},handleResponse:function(){return{}}});var ce=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.uuid,o=void 0===r?n.UUID:r,i=t.channels,a=void 0===i?[]:i,s=a.length>0?a.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(s),"/uuid/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channelGroups,r=void 0===n?[]:n,o={};return r.length>0&&(o["channel-group"]=r.join(",")),o},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s={};return 1===o.length&&0===a.length?s[o[0]]=t.payload:s=t.payload,{channels:s}}});var le=Object.freeze({__proto__:null,getOperation:function(){return U.PNSetStateOperation},validateParams:function(e,t){var n=e.config,r=t.state,o=t.channels,i=void 0===o?[]:o,a=t.channelGroups,s=void 0===a?[]:a;return r?n.subscribeKey?0===i.length&&0===s.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/presence/sub-key/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(i),"/uuid/").concat(j.encodeString(n.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.state,r=t.channelGroups,o=void 0===r?[]:r,i={};return i.state=JSON.stringify(n),o.length>0&&(i["channel-group"]=o.join(",")),i},handleResponse:function(e,t){return{state:t.payload}}});var pe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=t.channelGroups,a=void 0===i?[]:i,s="/v2/presence/sub-key/".concat(n.subscribeKey);if(o.length>0||a.length>0){var u=o.length>0?o.join(","):",";s+="/channel/".concat(j.encodeString(u))}return s},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,o=void 0===r?[]:r,i=t.includeUUIDs,a=void 0===i||i,s=t.includeState,u=void 0!==s&&s,c=t.queryParameters,l=void 0===c?{}:c,p={};return a||(p.disable_uuids=1),u&&(p.state=1),o.length>0&&(p["channel-group"]=o.join(",")),p=n(n({},p),l)},handleResponse:function(e,t,n){var r=n.channels,o=void 0===r?[]:r,i=n.channelGroups,a=void 0===i?[]:i,s=n.includeUUIDs,u=void 0===s||s,c=n.includeState,l=void 0!==c&&c;return o.length>1||a.length>0||0===a.length&&0===o.length?function(){var e={};return e.totalChannels=t.payload.total_channels,e.totalOccupancy=t.payload.total_occupancy,e.channels={},Object.keys(t.payload.channels).forEach((function(n){var r=t.payload.channels[n],o=[];return e.channels[n]={occupants:o,name:n,occupancy:r.occupancy},u&&r.uuids.forEach((function(e){l?o.push({state:e.state,uuid:e.uuid}):o.push({state:null,uuid:e})})),e})),e}():function(){var e={},n=[];return e.totalChannels=1,e.totalOccupancy=t.occupancy,e.channels={},e.channels[o[0]]={occupants:n,name:o[0],occupancy:t.occupancy},u&&t.uuids&&t.uuids.forEach((function(e){l?n.push({state:e.state,uuid:e.uuid}):n.push({state:null,uuid:e})})),e}()},handleError:function(e,t,n){402!==n.statusCode||this.getURL(e,t).includes("channel")||(n.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}});var he=Object.freeze({__proto__:null,getOperation:function(){return U.PNAddMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.action,o=t.channel;return t.messageTimetoken?n.subscribeKey?o?r?r.value?r.type?r.type.length>15?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var n=e.config,r=t.channel,o=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}});var fe=Object.freeze({__proto__:null,getOperation:function(){return U.PNRemoveMessageActionOperation},validateParams:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken;return t.messageTimetoken?o?n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config,r=t.channel,o=t.actionTimetoken,i=t.messageTimetoken;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r),"/message/").concat(i,"/action/").concat(o)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}});var de=Object.freeze({__proto__:null,getOperation:function(){return U.PNGetMessageActionsOperation},validateParams:function(e,t){var n=e.config,r=t.channel;return n.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channel;return"/v1/message-actions/".concat(n.subscribeKey,"/channel/").concat(j.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.limit,r=t.start,o=t.end,i={};return n&&(i.limit=n),r&&(i.start=r),o&&(i.end=o),i},handleResponse:function(e,t){var n={data:t.data,start:null,end:null};return n.data.length&&(n.end=n.data[n.data.length-1].actionTimetoken,n.start=n.data[0].actionTimetoken),n}}),ye={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel can't be empty"},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.limit&&(n.limit=t.limit),t.next&&(n.next=t.next),n},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},ge={getOperation:function(){return U.PNGenerateUploadUrlOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},me={getOperation:function(){return U.PNPublishFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.fileId)?(null==t?void 0:t.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var n=e.config,r=n.publishKey,o=n.subscribeKey,i=function(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(r,"/").concat(o,"/0/").concat(j.encodeString(t.channel),"/0/").concat(j.encodeString(i))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.ttl&&(n.ttl=t.ttl),void 0!==t.storeInHistory&&(n.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(n.meta=JSON.stringify(t.meta)),n},handleResponse:function(e,t){return{timetoken:t[2]}}},ve=function(e){var t=function(e){var t=this,n=e.generateUploadUrl,r=e.publishFile,a=e.modules,s=a.PubNubFile,u=a.config,c=a.cryptography,l=a.cryptoModule,p=a.networking;return function(e){var a=e.channel,h=e.file,f=e.message,d=e.cipherKey,y=e.meta,g=e.ttl,m=e.storeInHistory;return o(t,void 0,void 0,(function(){var e,t,o,v,b,_,S,w,O,P,E,T,A,C,k,N,M,j,R,x,U,I,D,F,G,L,K,B,H;return i(this,(function(i){switch(i.label){case 0:if(!a)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!h)throw new q("Validation failed, check status for details",z("file can't be empty"));return e=s.create(h),[4,n({channel:a,name:e.name})];case 1:return t=i.sent(),o=t.file_upload_request,v=o.url,b=o.form_fields,_=t.data,S=_.id,w=_.name,s.supportsEncryptFile&&(d||l)?null!=d?[3,3]:[4,l.encryptFile(e,s)]:[3,6];case 2:return O=i.sent(),[3,5];case 3:return[4,c.encryptFile(d,e,s)];case 4:O=i.sent(),i.label=5;case 5:e=O,i.label=6;case 6:P=b,e.mimeType&&(P=b.map((function(t){return"Content-Type"===t.key?{key:t.key,value:e.mimeType}:t}))),i.label=7;case 7:return i.trys.push([7,21,,22]),s.supportsFileUri&&h.uri?(A=(T=p).POSTFILE,C=[v,P],[4,e.toFileUri()]):[3,10];case 8:return[4,A.apply(T,C.concat([i.sent()]))];case 9:return E=i.sent(),[3,20];case 10:return s.supportsFile?(N=(k=p).POSTFILE,M=[v,P],[4,e.toFile()]):[3,13];case 11:return[4,N.apply(k,M.concat([i.sent()]))];case 12:return E=i.sent(),[3,20];case 13:return s.supportsBuffer?(R=(j=p).POSTFILE,x=[v,P],[4,e.toBuffer()]):[3,16];case 14:return[4,R.apply(j,x.concat([i.sent()]))];case 15:return E=i.sent(),[3,20];case 16:return s.supportsBlob?(I=(U=p).POSTFILE,D=[v,P],[4,e.toBlob()]):[3,19];case 17:return[4,I.apply(U,D.concat([i.sent()]))];case 18:return E=i.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(F=i.sent()).response&&"string"==typeof F.response.text?(G=F.response.text,L=/(.*)<\/Message>/gi.exec(G),new q(L?"Upload to bucket failed: ".concat(L[1]):"Upload to bucket failed.",F)):new q("Upload to bucket failed.",F);case 22:if(204!==E.status)throw new q("Upload to bucket was unsuccessful",E);K=u.fileUploadPublishRetryLimit,B=!1,H={timetoken:"0"},i.label=23;case 23:return i.trys.push([23,25,,26]),[4,r({channel:a,message:f,fileId:S,fileName:w,meta:y,storeInHistory:m,ttl:g})];case 24:return H=i.sent(),B=!0,[3,26];case 25:return i.sent(),K-=1,[3,26];case 26:if(!B&&K>0)return[3,23];i.label=27;case 27:if(B)return[2,{timetoken:H.timetoken,id:S,name:w}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:a,id:S,name:w})}}))}))}}(e);return function(e,n){var r=t(e);return"function"==typeof n?(r.then((function(e){return n(null,e)})).catch((function(e){return n(e,null)})),r):r}},be=function(e,t){var n=t.channel,r=t.id,o=t.name,i=e.config,a=e.networking,s=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",z("channel can't be empty"));if(!r)throw new q("Validation failed, check status for details",z("file id can't be empty"));if(!o)throw new q("Validation failed, check status for details",z("file name can't be empty"));var u="/v1/files/".concat(i.subscribeKey,"/channels/").concat(j.encodeString(n),"/files/").concat(r,"/").concat(o),c={};c.uuid=i.getUUID(),c.pnsdk=W(i);var l=s.getToken()||i.getAuthKey();l&&(c.auth=l),i.secretKey&&$(e,u,c,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var p=Object.keys(c).map((function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(c[e]))})).join("&");return""!==p?"".concat(a.getStandardOrigin()).concat(u,"?").concat(p):"".concat(a.getStandardOrigin()).concat(u)},_e={getOperation:function(){return U.PNDownloadFileOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.name)?(null==t?void 0:t.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t,n){var r=e.PubNubFile,a=e.config,s=e.cryptography,u=e.cryptoModule;return o(void 0,void 0,void 0,(function(){var e,o,c,l;return i(this,(function(i){switch(i.label){case 0:return e=t.response.body,r.supportsEncryptFile&&(n.cipherKey||u)?null!=n.cipherKey?[3,2]:[4,u.decryptFile(r.create({data:e,name:n.name}),r)]:[3,5];case 1:return o=i.sent().data,[3,4];case 2:return[4,s.decrypt(null!==(c=n.cipherKey)&&void 0!==c?c:a.cipherKey,e)];case 3:o=i.sent(),i.label=4;case 4:e=o,i.label=5;case 5:return[2,r.create({data:e,name:null!==(l=t.response.name)&&void 0!==l?l:n.name,mimeType:t.response.type})]}}))}))}},Se={getOperation:function(){return U.PNListFilesOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.id)?(null==t?void 0:t.name)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){var n=e.config;return"/v1/files/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},we={getOperation:function(){return U.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},Oe={getOperation:function(){return U.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Pe={getOperation:function(){return U.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o=e.config,i={};return i.uuid=null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:o.getUUID(),i.include=["status","type","custom"],(null==t?void 0:t.include)&&!1===(null===(r=t.include)||void 0===r?void 0:r.customFields)&&i.include.pop(),i.include=i.include.join(","),i},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ee={getOperation:function(){return U.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r=e.config;return{uuid:null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Te={getOperation:function(){return U.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){var t=e.config;return"/v2/objects/".concat(t.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["status","type"]};return(null==t?void 0:t.include)&&(null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),h.include=h.include.join(","),(null===(r=null==t?void 0:t.include)||void 0===r?void 0:r.totalCount)&&(h.count=null===(o=t.include)||void 0===o?void 0:o.totalCount),(null===(i=null==t?void 0:t.page)||void 0===i?void 0:i.next)&&(h.start=null===(a=t.page)||void 0===a?void 0:a.next),(null===(u=null==t?void 0:t.page)||void 0===u?void 0:u.prev)&&(h.end=null===(c=t.page)||void 0===c?void 0:c.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),h.limit=null!==(l=null==t?void 0:t.limit)&&void 0!==l?l:100,(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ae={getOperation:function(){return U.PNGetChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ce={getOperation:function(){return U.PNSetChannelMetadataOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r={include:["status","type","custom"]};return(null==t?void 0:t.include)&&!1===(null===(n=t.include)||void 0===n?void 0:n.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},ke={getOperation:function(){return U.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"Channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},Ne={getOperation:function(){return U.PNGetMembersOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channel))return"channel cannot be empty"},getURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&m.include.push("uuid"),(null===(i=t.include)||void 0===i?void 0:i.customUUIDFields)&&m.include.push("uuid.custom"),(null===(a=t.include)||void 0===a?void 0:a.UUIDStatusField)&&m.include.push("uuid.status"),(null===(u=t.include)||void 0===u?void 0:u.UUIDTypeField)&&m.include.push("uuid.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Me={getOperation:function(){return U.PNSetMembersOperation},validateParams:function(e,t){return(null==t?void 0:t.channel)?(null==t?void 0:t.uuids)&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n=e.config;return"/v2/objects/".concat(n.subscribeKey,"/channels/").concat(j.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.uuids.map((function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["uuid.status","uuid.type","type"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customUUIDFields)&&h.include.push("uuid.custom"),(null===(o=t.include)||void 0===o?void 0:o.UUIDFields)&&h.include.push("uuid")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},je={getOperation:function(){return U.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=null==t?void 0:t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h,f,d,y,g,m={include:[]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.statusField)&&m.include.push("status"),(null===(r=t.include)||void 0===r?void 0:r.customFields)&&m.include.push("custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&m.include.push("channel"),(null===(i=t.include)||void 0===i?void 0:i.customChannelFields)&&m.include.push("channel.custom"),(null===(a=t.include)||void 0===a?void 0:a.channelStatusField)&&m.include.push("channel.status"),(null===(u=t.include)||void 0===u?void 0:u.channelTypeField)&&m.include.push("channel.type")),m.include=m.include.join(","),(null===(c=null==t?void 0:t.include)||void 0===c?void 0:c.totalCount)&&(m.count=null===(l=t.include)||void 0===l?void 0:l.totalCount),(null===(p=null==t?void 0:t.page)||void 0===p?void 0:p.next)&&(m.start=null===(h=t.page)||void 0===h?void 0:h.next),(null===(f=null==t?void 0:t.page)||void 0===f?void 0:f.prev)&&(m.end=null===(d=t.page)||void 0===d?void 0:d.prev),(null==t?void 0:t.filter)&&(m.filter=t.filter),m.limit=null!==(y=null==t?void 0:t.limit)&&void 0!==y?y:100,(null==t?void 0:t.sort)&&(m.sort=Object.entries(null!==(g=t.sort)&&void 0!==g?g:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),m},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Re={getOperation:function(){return U.PNSetMembershipsOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){var n,r=e.config;return"/v2/objects/".concat(r.subscribeKey,"/uuids/").concat(j.encodeString(null!==(n=t.uuid)&&void 0!==n?n:r.getUUID()),"/channels")},patchPayload:function(e,t){var n;return(n={set:[],delete:[]})[t.type]=t.channels.map((function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}})),n},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n,r,o,i,a,u,c,l,p,h={include:["channel.status","channel.type","status"]};return(null==t?void 0:t.include)&&((null===(n=t.include)||void 0===n?void 0:n.customFields)&&h.include.push("custom"),(null===(r=t.include)||void 0===r?void 0:r.customChannelFields)&&h.include.push("channel.custom"),(null===(o=t.include)||void 0===o?void 0:o.channelFields)&&h.include.push("channel")),h.include=h.include.join(","),(null===(i=null==t?void 0:t.include)||void 0===i?void 0:i.totalCount)&&(h.count=!0),(null===(a=null==t?void 0:t.page)||void 0===a?void 0:a.next)&&(h.start=null===(u=t.page)||void 0===u?void 0:u.next),(null===(c=null==t?void 0:t.page)||void 0===c?void 0:c.prev)&&(h.end=null===(l=t.page)||void 0===l?void 0:l.prev),(null==t?void 0:t.filter)&&(h.filter=t.filter),null!=t.limit&&(h.limit=t.limit),(null==t?void 0:t.sort)&&(h.sort=Object.entries(null!==(p=t.sort)&&void 0!==p?p:{}).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"asc"===r||"desc"===r?"".concat(n,":").concat(r):n}))),h},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}};var xe=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/audit/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channel,r=t.channelGroup,o=t.authKeys,i=void 0===o?[]:o,a={};return n&&(a.channel=n),r&&(a["channel-group"]=r),i.length>0&&(a.auth=i.join(",")),a},handleResponse:function(e,t){return t.payload}});var Ue=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrant},validateParams:function(e,t){var n=e.config;return n.subscribeKey?n.publishKey?n.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){var t=e.config;return"/v2/auth/grant/sub-key/".concat(t.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.channelGroups,i=void 0===o?[]:o,a=t.uuids,s=void 0===a?[]:a,u=t.ttl,c=t.read,l=void 0!==c&&c,p=t.write,h=void 0!==p&&p,f=t.manage,d=void 0!==f&&f,y=t.get,g=void 0!==y&&y,m=t.join,v=void 0!==m&&m,b=t.update,_=void 0!==b&&b,S=t.authKeys,w=void 0===S?[]:S,O=t.delete,P={};return P.r=l?"1":"0",P.w=h?"1":"0",P.m=d?"1":"0",P.d=O?"1":"0",P.g=g?"1":"0",P.j=v?"1":"0",P.u=_?"1":"0",r.length>0&&(P.channel=r.join(",")),i.length>0&&(P["channel-group"]=i.join(",")),w.length>0&&(P.auth=w.join(",")),s.length>0&&(P["target-uuid"]=s.join(",")),(u||0===u)&&(P.ttl=u),P},handleResponse:function(){return{}}});function Ie(e){var t,n,r,o,i=void 0!==(null==e?void 0:e.authorizedUserId),a=void 0!==(null===(t=null==e?void 0:e.resources)||void 0===t?void 0:t.users),s=void 0!==(null===(n=null==e?void 0:e.resources)||void 0===n?void 0:n.spaces),u=void 0!==(null===(r=null==e?void 0:e.patterns)||void 0===r?void 0:r.users),c=void 0!==(null===(o=null==e?void 0:e.patterns)||void 0===o?void 0:o.spaces);return u||a||c||s||i}function De(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}function Fe(e,t){if(Ie(t))return function(e,t){var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorizedUserId,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.users,c=r.spaces,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.users,h=o.spaces,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}(0,t);var n=t.ttl,r=t.resources,o=t.patterns,i=t.meta,a=t.authorized_uuid,s={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(r){var u=r.uuids,c=r.channels,l=r.groups;u&&Object.keys(u).forEach((function(e){s.permissions.resources.uuids[e]=De(u[e])})),c&&Object.keys(c).forEach((function(e){s.permissions.resources.channels[e]=De(c[e])})),l&&Object.keys(l).forEach((function(e){s.permissions.resources.groups[e]=De(l[e])}))}if(o){var p=o.uuids,h=o.channels,f=o.groups;p&&Object.keys(p).forEach((function(e){s.permissions.patterns.uuids[e]=De(p[e])})),h&&Object.keys(h).forEach((function(e){s.permissions.patterns.channels[e]=De(h[e])})),f&&Object.keys(f).forEach((function(e){s.permissions.patterns.groups[e]=De(f[e])}))}return(n||0===n)&&(s.ttl=n),i&&(s.permissions.meta=i),a&&(s.permissions.uuid="".concat(a)),s}var Ge=Object.freeze({__proto__:null,getOperation:function(){return U.PNAccessManagerGrantToken},extractPermissions:De,validateParams:function(e,t){var n,r,o,i,a,s,u=e.config;if(!u.subscribeKey)return"Missing Subscribe Key";if(!u.publishKey)return"Missing Publish Key";if(!u.secretKey)return"Missing Secret Key";if(!t.resources&&!t.patterns)return"Missing either Resources or Patterns.";var c=void 0!==(null==t?void 0:t.authorized_uuid),l=void 0!==(null===(n=null==t?void 0:t.resources)||void 0===n?void 0:n.uuids),p=void 0!==(null===(r=null==t?void 0:t.resources)||void 0===r?void 0:r.channels),h=void 0!==(null===(o=null==t?void 0:t.resources)||void 0===o?void 0:o.groups),f=void 0!==(null===(i=null==t?void 0:t.patterns)||void 0===i?void 0:i.uuids),d=void 0!==(null===(a=null==t?void 0:t.patterns)||void 0===a?void 0:a.channels),y=void 0!==(null===(s=null==t?void 0:t.patterns)||void 0===s?void 0:s.groups),g=c||l||f||p||d||h||y;return Ie(t)&&g?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(e){var t=e.config;return"/v3/pam/".concat(t.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return Fe(0,t)},handleResponse:function(e,t){return t.data.token}}),Le={getOperation:function(){return U.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){var n=e.config;return"/v3/pam/".concat(n.subscribeKey,"/grant/").concat(j.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Ke(e,t){var n=JSON.stringify(t);if(e.cryptoModule){var r=e.cryptoModule.encrypt(n);n="string"==typeof r?r:v(r),n=JSON.stringify(n)}return n||""}var Be=Object.freeze({__proto__:null,getOperation:function(){return U.PNPublishOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){var n=t.sendByPost;return void 0!==n&&n},getURL:function(e,t){var n=e.config,r=t.channel,o=Ke(e,t.message);return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0/").concat(j.encodeString(o))},postURL:function(e,t){var n=e.config,r=t.channel;return"/publish/".concat(n.publishKey,"/").concat(n.subscribeKey,"/0/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Ke(e,t.message)},prepareParams:function(e,t){var n=t.meta,r=t.replicate,o=void 0===r||r,i=t.storeInHistory,a=t.ttl,s={};return null!=i&&(s.store=i?"1":"0"),a&&(s.ttl=a),!1===o&&(s.norep="true"),n&&"object"==typeof n&&(s.meta=JSON.stringify(n)),s},handleResponse:function(e,t){return{timetoken:t[2]}}});var He=Object.freeze({__proto__:null,getOperation:function(){return U.PNSignalOperation},validateParams:function(e,t){var n=e.config,r=t.message;return t.channel?r?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var n,r=e.config,o=t.channel,i=t.message,a=(n=i,JSON.stringify(n));return"/signal/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(j.encodeString(o),"/0/").concat(j.encodeString(a))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}});var qe=Object.freeze({__proto__:null,getOperation:function(){return U.PNHistoryOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channel,r=e.config;return"/v2/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o=t.reverse,i=t.count,a=void 0===i?100:i,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p={include_token:"true"};return p.count=a,n&&(p.start=n),r&&(p.end=r),u&&(p.string_message_token="true"),null!=o&&(p.reverse=o.toString()),l&&(p.include_meta="true"),p},handleResponse:function(e,t){var n={messages:[],startTimeToken:t[1],endTimeToken:t[2]};return Array.isArray(t[0])&&t[0].forEach((function(t){var r=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message),o={timetoken:t.timetoken,entry:r.payload};t.meta&&(o.meta=t.meta),r.error&&(o.error=r.error),n.messages.push(o)})),n}});var ze=Object.freeze({__proto__:null,getOperation:function(){return U.PNDeleteMessagesOperation},validateParams:function(e,t){var n=t.channel,r=e.config;return n?r.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){var n=t.channel,r=e.config;return"/v3/history/sub-key/".concat(r.subscribeKey,"/channel/").concat(j.encodeString(n))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.start,r=t.end,o={};return n&&(o.start=n),r&&(o.end=r),o},handleResponse:function(e,t){return t.payload}});var Ve=Object.freeze({__proto__:null,getOperation:function(){return U.PNMessageCounts},validateParams:function(e,t){var n=t.channels,r=t.timetoken,o=t.channelTimetokens,i=e.config;return n?r&&o?"timetoken and channelTimetokens are incompatible together":o&&o.length>1&&n.length!==o.length?"Length of channelTimetokens and channels do not match":i.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){var n=t.channels,r=e.config,o=n.join(",");return"/v3/history/sub-key/".concat(r.subscribeKey,"/message-counts/").concat(j.encodeString(o))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.timetoken,r=t.channelTimetokens,o={};if(r&&1===r.length){var i=s(r,1)[0];o.timetoken=i}else r?o.channelsTimetoken=r.join(","):n&&(o.timetoken=n);return o},handleResponse:function(e,t){return{channels:t.channels}}});var We=Object.freeze({__proto__:null,getOperation:function(){return U.PNFetchMessagesOperation},validateParams:function(e,t){var n=t.channels,r=t.includeMessageActions,o=void 0!==r&&r,i=e.config;if(!n||0===n.length)return"Missing channels";if(!i.subscribeKey)return"Missing Subscribe Key";if(o&&n.length>1)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var n=t.channels,r=void 0===n?[]:n,o=t.includeMessageActions,i=void 0!==o&&o,a=e.config,s=i?"history-with-actions":"history",u=r.length>0?r.join(","):",";return"/v3/".concat(s,"/sub-key/").concat(a.subscribeKey,"/channel/").concat(j.encodeString(u))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=t.channels,r=t.start,o=t.end,i=t.includeMessageActions,a=t.count,s=t.stringifiedTimeToken,u=void 0!==s&&s,c=t.includeMeta,l=void 0!==c&&c,p=t.includeUuid,h=t.includeUUID,f=void 0===h||h,d=t.includeMessageType,y=void 0===d||d,g={};return g.max=a||(n.length>1||!0===i?25:100),r&&(g.start=r),o&&(g.end=o),u&&(g.string_message_token="true"),l&&(g.include_meta="true"),f&&!1!==p&&(g.include_uuid="true"),y&&(g.include_message_type="true"),g},handleResponse:function(e,t){var n={channels:{}};return Object.keys(t.channels||{}).forEach((function(r){n.channels[r]=[],(t.channels[r]||[]).forEach((function(t){var o={},i=function(e,t){var n={};if(!e.cryptoModule)return n.payload=t,n;try{var r=e.cryptoModule.decrypt(t),o=r instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r;return n.payload=o,n}catch(r){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",r.message),n.payload=t,n.error="Error while decrypting message content: ".concat(r.message)}return n}(e,t.message);o.channel=r,o.timetoken=t.timetoken,o.message=i.payload,o.messageType=t.message_type,o.uuid=t.uuid,t.actions&&(o.actions=t.actions,o.data=t.actions),t.meta&&(o.meta=t.meta),i.error&&(o.error=i.error),n.channels[r].push(o)}))})),t.more&&(n.more=t.more),n}});var Je=Object.freeze({__proto__:null,getOperation:function(){return U.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}});var $e=Object.freeze({__proto__:null,getOperation:function(){return U.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var n=e.config,r=t.channels,o=void 0===r?[]:r,i=o.length>0?o.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(i),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n=e.config,r=t.state,o=t.channelGroups,i=void 0===o?[]:o,a=t.timetoken,s=t.filterExpression,u=t.region,c={heartbeat:n.getPresenceTimeout()};return i.length>0&&(c["channel-group"]=i.join(",")),s&&s.length>0&&(c["filter-expr"]=s),Object.keys(r).length&&(c.state=JSON.stringify(r)),a&&(c.tt=a),u&&(c.tr=u),c},handleResponse:function(e,t){var n=[];t.m.forEach((function(e){var t={publishTimetoken:e.p.t,region:e.p.r},r={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(r)}));var r={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:r}}}),Qe={getOperation:function(){return U.PNHandshakeOperation},validateParams:function(e,t){if(!(null==t?void 0:t.channels)&&!(null==t?void 0:t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),n.tt=0,t.state&&(n.state=JSON.stringify(t.state)),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.ee="",n},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Xe={getOperation:function(){return U.PNReceiveMessagesOperation},validateParams:function(e,t){return(null==t?void 0:t.channels)||(null==t?void 0:t.channelGroups)?(null==t?void 0:t.timetoken)?(null==t?void 0:t.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){var n=e.config,r=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(n.subscribeKey,"/").concat(j.encodeString(r),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var n={};return t.channelGroups&&t.channelGroups.length>0&&(n["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&t.filterExpression.length>0&&(n["filter-expr"]=t.filterExpression),n.tt=t.timetoken,n.tr=t.region,n.ee="",n},handleResponse:function(e,t){var n=[];return t.m.forEach((function(e){var t={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};n.push(t)})),{messages:n,metadata:{region:t.t.r,timetoken:t.t.t}}}},Ye=function(){function e(e){void 0===e&&(e=!1),this.sync=e,this.listeners=new Set}return e.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},e.prototype.notify=function(e){var t=this,n=function(){t.listeners.forEach((function(t){t(e)}))};this.sync?n():setTimeout(n,0)},e}(),Ze=function(){function e(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return e.prototype.transition=function(e,t){var n;if(this.transitionMap.has(t.type))return null===(n=this.transitionMap.get(t.type))||void 0===n?void 0:n(e,t)},e.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},e.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},e.prototype.onEnter=function(e){return this.enterEffects.push(e),this},e.prototype.onExit=function(e){return this.exitEffects.push(e),this},e}(),et=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.describe=function(e){return new Ze(e)},n.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},n.prototype.transition=function(e){var t,n,r,o,i,u;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var c=this.currentState.transition(this.currentContext,e);if(c){var l=s(c,3),p=l[0],h=l[1],f=l[2];try{for(var d=a(this.currentState.exitEffects),y=d.next();!y.done;y=d.next()){var g=y.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}var m=this.currentState;this.currentState=p;var v=this.currentContext;this.currentContext=h,this.notify({type:"transitionDone",fromState:m,fromContext:v,toState:p,toContext:h,event:e});try{for(var b=a(f),_=b.next();!_.done;_=b.next()){g=_.value;this.notify({type:"invocationDispatched",invocation:g})}}catch(e){r={error:e}}finally{try{_&&!_.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}try{for(var S=a(this.currentState.enterEffects),w=S.next();!w.done;w=S.next()){g=w.value;this.notify({type:"invocationDispatched",invocation:g(this.currentContext)})}}catch(e){i={error:e}}finally{try{w&&!w.done&&(u=S.return)&&u.call(S)}finally{if(i)throw i.error}}}},n}(Ye),tt=function(){function e(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}return e.prototype.on=function(e,t){this.handlers.set(e,t)},e.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));var n=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,n),n.start()}else if(this.instances.has(e.payload)){var r=this.instances.get(e.payload);null==r||r.cancel(),this.instances.delete(e.payload)}},e.prototype.dispose=function(){var e,t;try{for(var n=a(this.instances.entries()),r=n.next();!r.done;r=n.next()){var o=s(r.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},e}();function nt(e,t){var n=function(){for(var n=[],r=0;r0&&r(e),[2]}))}))}))),a.on(ht.type,ut((function(e,t,n){var r=n.emitStatus;return o(a,void 0,void 0,(function(){return i(this,(function(t){return r(e),[2]}))}))}))),a.on(ft.type,ut((function(e,n,r){var s=r.receiveMessages,u=r.delay,c=r.config;return o(a,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return c.retryConfiguration&&c.retryConfiguration.shouldRetry(e.reason,e.attempts)?(n.throwIfAborted(),[4,u(c.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),n.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,s({abortSignal:n,channels:e.channels,channelGroups:e.groups,timetoken:e.cursor.timetoken,region:e.cursor.region,filterExpression:c.filterExpression})];case 3:return r=i.sent(),[2,t.transition(Pt(r.metadata,r.messages))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Et(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Tt(new q(c.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a.on(dt.type,ut((function(e,r,s){var u=s.handshake,c=s.delay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({abortSignal:r,channels:e.channels,channelGroups:e.groups,filterExpression:p.filterExpression},p.maintainPresenceState&&{state:l}))];case 3:return o=i.sent(),[2,t.transition(bt(o))];case 4:return(a=i.sent())instanceof Error&&"Aborted"===a.message?[2]:a instanceof q?[2,t.transition(_t(a))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(St(new q(p.retryConfiguration.getGiveupReason(e.reason,e.attempts))))];case 7:return[2]}}))}))}))),a}return t(r,e),r}(tt),Mt=new Ze("HANDSHAKE_FAILED");Mt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Mt.on(Ct.type,(function(e,t){return Ft.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})})),Mt.on(gt.type,(function(e,t){var n,r;return Ft.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!==(r=null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.region)&&void 0!==r?r:0}})})),Mt.on(kt.type,(function(e){return Gt.with()}));var jt=new Ze("HANDSHAKE_STOPPED");jt.on(yt.type,(function(e,t){return jt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),jt.on(Ct.type,(function(e,t){return Ft.with(n(n({},e),{cursor:t.payload.cursor||e.cursor}))})),jt.on(gt.type,(function(e,t){var n;return jt.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?void 0:n.region)||0}})})),jt.on(kt.type,(function(e){return Gt.with()}));var Rt=new Ze("RECEIVE_FAILED");Rt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Rt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Rt.on(kt.type,(function(e){return Gt.with(void 0)}));var xt=new Ze("RECEIVE_STOPPED");xt.on(yt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),xt.on(gt.type,(function(e,t){return xt.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(Ct.type,(function(e,t){var n;return Ft.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null===(n=t.payload.cursor)||void 0===n?void 0:n.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),xt.on(kt.type,(function(){return Gt.with(void 0)}));var Ut=new Ze("RECEIVE_RECONNECTING");Ut.onEnter((function(e){return ft(e)})),Ut.onExit((function(){return ft.cancel})),Ut.on(Pt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),Ut.on(Et.type,(function(e,t){return Ut.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Ut.on(Tt.type,(function(e,t){var n;return Rt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNDisconnectedUnexpectedlyCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Ut.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),Ut.on(gt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),Ut.on(yt.type,(function(e,t){return It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ut.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var It=new Ze("RECEIVING");It.onEnter((function(e){return lt(e.channels,e.groups,e.cursor)})),It.onExit((function(){return lt.cancel})),It.on(wt.type,(function(e,t){return It.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[pt(t.payload.events)])})),It.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})})),It.on(gt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):It.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})})),It.on(Ot.type,(function(e,t){return Ut.with(n(n({},e),{attempts:0,reason:t.payload}))})),It.on(At.type,(function(e){return xt.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[ht({category:R.PNDisconnectedCategory})])})),It.on(kt.type,(function(e){return Gt.with(void 0,[ht({category:R.PNDisconnectedCategory})])}));var Dt=new Ze("HANDSHAKE_RECONNECTING");Dt.onEnter((function(e){return dt(e)})),Dt.onExit((function(){return dt.cancel})),Dt.on(bt.type,(function(e,t){var n,r,o={timetoken:(null===(n=e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=e.cursor)||void 0===r?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return It.with({channels:e.channels,groups:e.groups,cursor:o},[ht({category:R.PNConnectedCategory})])})),Dt.on(_t.type,(function(e,t){return Dt.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),Dt.on(St.type,(function(e,t){var n;return Mt.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[ht({category:R.PNConnectionErrorCategory,error:null===(n=t.payload)||void 0===n?void 0:n.message})])})),Dt.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Dt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Dt.on(gt.type,(function(e,t){var n,r;return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null===(n=t.payload.cursor)||void 0===n?void 0:n.region)||(null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.region)||0}})})),Dt.on(kt.type,(function(e){return Gt.with(void 0)}));var Ft=new Ze("HANDSHAKING");Ft.onEnter((function(e){return ct(e.channels,e.groups)})),Ft.onExit((function(){return ct.cancel})),Ft.on(yt.type,(function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?Gt.with(void 0):Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})})),Ft.on(mt.type,(function(e,t){var n,r;return It.with({channels:e.channels,groups:e.groups,cursor:{timetoken:(null===(n=null==e?void 0:e.cursor)||void 0===n?void 0:n.timetoken)?null===(r=null==e?void 0:e.cursor)||void 0===r?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[ht({category:R.PNConnectedCategory})])})),Ft.on(vt.type,(function(e,t){return Dt.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})})),Ft.on(At.type,(function(e){return jt.with({channels:e.channels,groups:e.groups,cursor:e.cursor})})),Ft.on(gt.type,(function(e,t){var n;return Ft.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?void 0:n.region)||0}})})),Ft.on(kt.type,(function(e){return Gt.with()}));var Gt=new Ze("UNSUBSCRIBED");Gt.on(yt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups})})),Gt.on(gt.type,(function(e,t){return Ft.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}));var Lt=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new Nt(this.engine,e),this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(Gt,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n=e.channels,r=e.channelGroups,o=e.timetoken,i=e.withPresence;this.channels=u(u([],s(this.channels),!1),s(null!=n?n:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=r?r:[]),!1),i&&(this.channels.map((function(e){return t.channels.push("".concat(e,"-pnpres"))})),this.groups.map((function(e){return t.groups.push("".concat(e,"-pnpres"))}))),o?this.engine.transition(gt(this.channels,this.groups,o)):this.engine.transition(yt(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter((function(e){return!e.endsWith("-pnpres")})),groups:this.groups.filter((function(e){return!e.endsWith("-pnpres")}))})},e.prototype.unsubscribe=function(e){var t=this,n=e.channels,r=e.groups,o=null==n?void 0:n.slice(0);null==n||n.map((function(e){return o.push("".concat(e,"-pnpres"))})),this.channels=this.channels.filter((function(e){return!(null==o?void 0:o.includes(e))}));var i=null==r?void 0:r.slice(0);null==r||r.map((function(e){return i.push("".concat(e,"-pnpres"))})),this.groups=this.groups.filter((function(e){return!(null==i?void 0:i.includes(e))})),this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:n,groups:r})},e.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(yt(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.reconnect=function(e){var t=e.timetoken,n=e.region;this.engine.transition(Ct(t,n))},e.prototype.disconnect=function(){this.engine.transition(At()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},e.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},e.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},e.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),Kt=nt("RECONNECT",(function(){return{}})),Bt=nt("DISCONNECT",(function(){return{}})),Ht=nt("JOINED",(function(e,t){return{channels:e,groups:t}})),qt=nt("LEFT",(function(e,t){return{channels:e,groups:t}})),zt=nt("LEFT_ALL",(function(){return{}})),Vt=nt("HEARTBEAT_SUCCESS",(function(e){return{statusCode:e}})),Wt=nt("HEARTBEAT_FAILURE",(function(e){return e})),Jt=nt("HEARTBEAT_GIVEUP",(function(){return{}})),$t=nt("TIMES_UP",(function(){return{}})),Qt=rt("HEARTBEAT",(function(e,t){return{channels:e,groups:t}})),Xt=rt("LEAVE",(function(e,t){return{channels:e,groups:t}})),Yt=rt("EMIT_STATUS",(function(e){return e})),Zt=ot("WAIT",(function(){return{}})),en=ot("DELAYED_HEARTBEAT",(function(e){return e})),tn=function(e){function r(t,r){var a=e.call(this,r)||this;return a.on(Qt.type,ut((function(e,r,s){var u=s.heartbeat,c=s.presenceState,l=s.config;return o(a,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,u(n({channels:e.channels,channelGroups:e.groups},l.maintainPresenceState&&{state:c}))];case 1:return o.sent(),t.transition(Vt(200)),[3,3];case 2:return(r=o.sent())instanceof q?[2,t.transition(Wt(r))]:[3,3];case 3:return[2]}}))}))}))),a.on(Xt.type,ut((function(e,t,n){var r=n.leave,s=n.config;return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(s.suppressLeaveEvents)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r({channels:e.channels,channelGroups:e.groups})];case 2:case 3:return t.sent(),[3,4];case 4:return[2]}}))}))}))),a.on(Zt.type,ut((function(e,n,r){var s=r.heartbeatDelay;return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return n.throwIfAborted(),[4,s()];case 1:return e.sent(),n.throwIfAborted(),[2,t.transition($t())]}}))}))}))),a.on(en.type,ut((function(e,r,s){var u=s.heartbeat,c=s.retryDelay,l=s.presenceState,p=s.config;return o(a,void 0,void 0,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return p.retryConfiguration&&p.retryConfiguration.shouldRetry(e.reason,e.attempts)?(r.throwIfAborted(),[4,c(p.retryConfiguration.getDelay(e.attempts,e.reason))]):[3,6];case 1:i.sent(),r.throwIfAborted(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,u(n({channels:e.channels,channelGroups:e.groups},p.maintainPresenceState&&{state:l}))];case 3:return i.sent(),[2,t.transition(Vt(200))];case 4:return(o=i.sent())instanceof Error&&"Aborted"===o.message?[2]:o instanceof q?[2,t.transition(Wt(o))]:[3,5];case 5:return[3,7];case 6:return[2,t.transition(Jt())];case 7:return[2]}}))}))}))),a.on(Yt.type,ut((function(e,t,r){var s=r.emitStatus,u=r.config;return o(a,void 0,void 0,(function(){var t;return i(this,(function(r){return u.announceFailedHeartbeats&&!0===(null===(t=null==e?void 0:e.status)||void 0===t?void 0:t.error)?s(e.status):u.announceSuccessfulHeartbeats&&200===e.statusCode&&s(n(n({},e),{operation:U.PNHeartbeatOperation,error:!1})),[2]}))}))}))),a}return t(r,e),r}(tt),nn=new Ze("HEARTBEAT_STOPPED");nn.on(Ht.type,(function(e,t){return nn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),nn.on(qt.type,(function(e,t){return nn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))})})),nn.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),nn.on(zt.type,(function(e,t){return un.with(void 0)}));var rn=new Ze("HEARTBEAT_COOLDOWN");rn.onEnter((function(){return Zt()})),rn.onExit((function(){return Zt.cancel})),rn.on($t.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),rn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),rn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),rn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),rn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var on=new Ze("HEARTBEAT_FAILED");on.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),on.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),on.on(Kt.type,(function(e,t){return sn.with({channels:e.channels,groups:e.groups})})),on.on(Bt.type,(function(e,t){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),on.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var an=new Ze("HEARBEAT_RECONNECTING");an.onEnter((function(e){return en(e)})),an.onExit((function(){return en.cancel})),an.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),an.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),an.on(Bt.type,(function(e,t){nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),an.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),an.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:e.attempts+1,reason:t.payload}))})),an.on(Jt.type,(function(e,t){return on.with({channels:e.channels,groups:e.groups})})),an.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var sn=new Ze("HEARTBEATING");sn.onEnter((function(e){return Qt(e.channels,e.groups)})),sn.on(Vt.type,(function(e,t){return rn.with({channels:e.channels,groups:e.groups})})),sn.on(Ht.type,(function(e,t){return sn.with({channels:u(u([],s(e.channels),!1),s(t.payload.channels),!1),groups:u(u([],s(e.groups),!1),s(t.payload.groups),!1)})})),sn.on(qt.type,(function(e,t){return sn.with({channels:e.channels.filter((function(e){return!t.payload.channels.includes(e)})),groups:e.groups.filter((function(e){return!t.payload.groups.includes(e)}))},[Xt(t.payload.channels,t.payload.groups)])})),sn.on(Wt.type,(function(e,t){return an.with(n(n({},e),{attempts:0,reason:t.payload}))})),sn.on(Bt.type,(function(e){return nn.with({channels:e.channels,groups:e.groups},[Xt(e.channels,e.groups)])})),sn.on(zt.type,(function(e,t){return un.with(void 0,[Xt(e.channels,e.groups)])}));var un=new Ze("HEARTBEAT_INACTIVE");un.on(Ht.type,(function(e,t){return sn.with({channels:t.payload.channels,groups:t.payload.groups})}));var cn=function(){function e(e){var t=this;this.engine=new et,this.channels=[],this.groups=[],this.dispatcher=new tn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe((function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)})),this.engine.start(un,void 0)}return Object.defineProperty(e.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),e.prototype.join=function(e){var t=e.channels,n=e.groups;this.channels=u(u([],s(this.channels),!1),s(null!=t?t:[]),!1),this.groups=u(u([],s(this.groups),!1),s(null!=n?n:[]),!1),this.engine.transition(Ht(this.channels.slice(0),this.groups.slice(0)))},e.prototype.leave=function(e){var t=this,n=e.channels,r=e.groups;this.dependencies.presenceState&&(null==n||n.forEach((function(e){return delete t.dependencies.presenceState[e]})),null==r||r.forEach((function(e){return delete t.dependencies.presenceState[e]}))),this.engine.transition(qt(null!=n?n:[],null!=r?r:[]))},e.prototype.leaveAll=function(){this.engine.transition(zt())},e.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},e}(),ln=function(){function e(){}return e.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:this.delay)+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){var n;return 403!==(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){var n;return 1e3*((null!==(n=t.retryAfter)&&void 0!==n?n:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason:function(e,t){var n;return this.maximumRetry<=t?"retry attempts exhaused.":403===(null===(n=null==e?void 0:e.status)||void 0===n?void 0:n.statusCode)?"forbidden operation.":"unknown error"}}},e}(),pn=function(){function e(e){var t=e.modules,n=e.listenerManager,r=e.getFileUrl;this.modules=t,this.listenerManager=n,this.getFileUrl=r,t.cryptoModule&&(this._decoder=new TextDecoder)}return e.prototype.emitEvent=function(e){var t=e.channel,o=e.publishMetaData,i=e.subscriptionMatch;if(t===i&&(i=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=o.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType){(a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a)}else if(2===e.messageType){if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type){var s=this._renameChannelField(a);this.listenerManager.announceUser(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"user"})}))}else if("channel"===message.payload.type){s=this._renameChannelField(a);this.listenerManager.announceSpace(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),type:"space"})}))}else if("membership"===message.payload.type){var u=(s=this._renameChannelField(a)).message.data,c=u.uuid,l=u.channel,p=r(u,["uuid","channel"]);p.user=c,p.space=l,this.listenerManager.announceMembership(n(n({},s),{message:n(n({},s.message),{event:this._renameEvent(s.message.event),data:p})}))}}else if(3===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a)}else if(4===e.messageType){(a={}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId;var h=e.payload;if(this.modules.cryptoModule){var f=void 0;try{f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==f&&(h=f)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=h.message,a.file={id:h.file.id,name:h.file.name,url:this.getFileUrl({id:h.file.id,name:h.file.name,channel:t})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=t,a.subscription=i,a.timetoken=o.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){f=void 0;try{var d;f=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){f=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=f?f:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},e.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},e.prototype._renameChannelField=function(e){var t=e.channel,n=r(e,["channel"]);return n.spaceId=t,n},e}(),hn=function(){function e(e){var t=this,r=e.networking,o=e.cbor,i=new g({setup:e});this._config=i;var c=new A({config:i}),l=e.cryptography;r.init(i);var p=new H(i,o);this._tokenManager=p;var h=new I({maximumSamplesCount:6e4});this._telemetryManager=h;var f=this._config.cryptoModule,d={config:i,networking:r,crypto:c,cryptography:l,tokenManager:p,telemetryManager:h,PubNubFile:e.PubNubFile,cryptoModule:f};this.File=e.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.encryptFile(t,this.File)):l.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&d.cryptoModule?(t=e,d.cryptoModule.decryptFile(t,this.File)):l.decryptFile(e,t,this.File)};var y=Q.bind(this,d,Je),m=Q.bind(this,d,ae),b=Q.bind(this,d,ue),_=Q.bind(this,d,le),S=Q.bind(this,d,$e),w=new B;if(this._listenerManager=w,this.iAmHere=Q.bind(this,d,ue),this.iAmAway=Q.bind(this,d,ae),this.setPresenceState=Q.bind(this,d,le),this.handshake=Q.bind(this,d,Qe),this.receiveMessages=Q.bind(this,d,Xe),!0===i.enableEventEngine){if(this._eventEmitter=new pn({modules:d,listenerManager:this._listenerManager,getFileUrl:function(e){return be(d,e)}}),i.maintainPresenceState&&(this.presenceState={},this.setState=function(e){var n,r;return null===(n=e.channels)||void 0===n||n.forEach((function(n){return t.presenceState[n]=e.state})),null===(r=e.channelGroups)||void 0===r||r.forEach((function(n){return t.presenceState[n]=e.state})),t.setPresenceState({channels:e.channels,channelGroups:e.channelGroups,state:t.presenceState})}),i.getHeartbeatInterval()){var O=new cn({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise((function(e){return setTimeout(e,1e3*d.config.getHeartbeatInterval())}))},retryDelay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},config:d.config,presenceState:this.presenceState,emitStatus:function(e){w.announceStatus(e)}});this.presenceEventEngine=O,this.join=this.presenceEventEngine.join.bind(O),this.leave=this.presenceEventEngine.leave.bind(O),this.leaveAll=this.presenceEventEngine.leaveAll.bind(O)}var P=new Lt({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(e){return new Promise((function(t){return setTimeout(t,e)}))},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:d.config,emitMessages:function(e){var n,r;try{for(var o=a(e),i=o.next();!i.done;i=o.next()){var s=i.value;t._eventEmitter.emitEvent(s)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},emitStatus:function(e){w.announceStatus(e)}});this.subscribe=P.subscribe.bind(P),this.unsubscribe=P.unsubscribe.bind(P),this.unsubscribeAll=P.unsubscribeAll.bind(P),this.reconnect=P.reconnect.bind(P),this.disconnect=P.disconnect.bind(P),this.destroy=P.dispose.bind(P),this.getSubscribedChannels=P.getSubscribedChannels.bind(P),this.getSubscribedChannelGroups=P.getSubscribedChannelGroups.bind(P),this.eventEngine=P}else{var E=new x({timeEndpoint:y,leaveEndpoint:m,heartbeatEndpoint:b,setStateEndpoint:_,subscribeEndpoint:S,crypto:d.crypto,config:d.config,listenerManager:w,getFileUrl:function(e){return be(d,e)},cryptoModule:d.cryptoModule});this.subscribe=E.adaptSubscribeChange.bind(E),this.unsubscribe=E.adaptUnsubscribeChange.bind(E),this.disconnect=E.disconnect.bind(E),this.reconnect=E.reconnect.bind(E),this.unsubscribeAll=E.unsubscribeAll.bind(E),this.getSubscribedChannels=E.getSubscribedChannels.bind(E),this.getSubscribedChannelGroups=E.getSubscribedChannelGroups.bind(E),this.setState=E.adaptStateChange.bind(E),this.presence=E.adaptPresenceChange.bind(E),this.destroy=function(e){E.unsubscribeAll(e),E.disconnect()}}this.addListener=w.addListener.bind(w),this.removeListener=w.removeListener.bind(w),this.removeAllListeners=w.removeAllListeners.bind(w),this.parseToken=p.parseToken.bind(p),this.setToken=p.setToken.bind(p),this.getToken=p.getToken.bind(p),this.channelGroups={listGroups:Q.bind(this,d,ee),listChannels:Q.bind(this,d,te),addChannels:Q.bind(this,d,X),removeChannels:Q.bind(this,d,Y),deleteGroup:Q.bind(this,d,Z)},this.push={addChannels:Q.bind(this,d,ne),removeChannels:Q.bind(this,d,re),deleteDevice:Q.bind(this,d,ie),listChannels:Q.bind(this,d,oe)},this.hereNow=Q.bind(this,d,pe),this.whereNow=Q.bind(this,d,se),this.getState=Q.bind(this,d,ce),this.grant=Q.bind(this,d,Ue),this.grantToken=Q.bind(this,d,Ge),this.audit=Q.bind(this,d,xe),this.revokeToken=Q.bind(this,d,Le),this.publish=Q.bind(this,d,Be),this.fire=function(e,n){return e.replicate=!1,e.storeInHistory=!1,t.publish(e,n)},this.signal=Q.bind(this,d,He),this.history=Q.bind(this,d,qe),this.deleteMessages=Q.bind(this,d,ze),this.messageCounts=Q.bind(this,d,Ve),this.fetchMessages=Q.bind(this,d,We),this.addMessageAction=Q.bind(this,d,he),this.removeMessageAction=Q.bind(this,d,fe),this.getMessageActions=Q.bind(this,d,de),this.listFiles=Q.bind(this,d,ye);var T=Q.bind(this,d,ge);this.publishFile=Q.bind(this,d,me),this.sendFile=ve({generateUploadUrl:T,publishFile:this.publishFile,modules:d}),this.getFileUrl=function(e){return be(d,e)},this.downloadFile=Q.bind(this,d,_e),this.deleteFile=Q.bind(this,d,Se),this.objects={getAllUUIDMetadata:Q.bind(this,d,we),getUUIDMetadata:Q.bind(this,d,Oe),setUUIDMetadata:Q.bind(this,d,Pe),removeUUIDMetadata:Q.bind(this,d,Ee),getAllChannelMetadata:Q.bind(this,d,Te),getChannelMetadata:Q.bind(this,d,Ae),setChannelMetadata:Q.bind(this,d,Ce),removeChannelMetadata:Q.bind(this,d,ke),getChannelMembers:Q.bind(this,d,Ne),setChannelMembers:function(e){for(var r=[],o=1;o=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},e.prototype.hasModule=function(e){return e in this._modules},e.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},e.prototype.getStandardOrigin=function(){return this._standardOrigin},e.prototype.POSTFILE=function(e,t,n){return this._modules.postfile(e,t,n)},e.prototype.GETFILE=function(e,t,n){return this._modules.getfile(e,t,n)},e.prototype.POST=function(e,t,n,r){return this._modules.post(e,t,n,r)},e.prototype.PATCH=function(e,t,n,r){return this._modules.patch(e,t,n,r)},e.prototype.GET=function(e,t,n){return this._modules.get(e,t,n)},e.prototype.DELETE=function(e,t,n){return this._modules.del(e,t,n)},e.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return R.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return R.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return R.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return R.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return R.PNNetworkIssuesCategory;if(e.timeout)return R.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return R.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return R.PNBadRequestCategory;if(e.response.forbidden)return R.PNAccessDeniedCategory}return R.PNUnknownCategory},e}();function dn(e){var t=function(e){return e&&"object"==typeof e&&e.constructor===Object};if(!t(e))return e;var n={};return Object.keys(e).forEach((function(r){var o=function(e){return"string"==typeof e||e instanceof String}(r),i=r,a=e[r];Array.isArray(r)||o&&r.indexOf(",")>=0?i=(o?r.split(","):r).reduce((function(e,t){return e+=String.fromCharCode(t)}),""):(function(e){return"number"==typeof e&&isFinite(e)}(r)||o&&!isNaN(r))&&(i=String.fromCharCode(o?parseInt(r,10):10));n[i]=t(a)?dn(a):a})),n}var yn=function(){function e(e,t){this._base64ToBinary=t,this._decode=e}return e.prototype.decodeToken=function(e){var t="";e.length%4==3?t="=":e.length%4==2&&(t="==");var n=e.replace(/-/gi,"+").replace(/_/gi,"/")+t,r=this._decode(this._base64ToBinary(n));if("object"==typeof r)return r},e}(),gn={exports:{}},mn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;oa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;st?1:0}function Cn(e,t,n,r){void 0===r&&(r=On());var o,i=kn(e,"",0,[],void 0,0,r)||e;try{o=0===wn.length?JSON.stringify(i,t,n):JSON.stringify(i,Nn(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==Sn.length;){var a=Sn.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}}return o}function kn(e,t,n,r,o,i,a){var s;if(i+=1,"object"==typeof e&&null!==e){for(s=0;sa.depthLimit)return void En(bn,e,t,o);if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)return void En(bn,e,t,o);if(r.push(e),Array.isArray(e))for(s=0;s0)for(var r=0;r1&&"boolean"!=typeof t)throw new Hn('"allowMissing" argument must be a boolean');var n=cr(e),r=n.length>0?n[0]:"",o=lr("%"+r+"%",t),i=o.name,a=o.value,s=!1,u=o.alias;u&&(r=u[0],or(n,rr([0,1],u)));for(var c=1,l=!0;c=n.length){var d=zn(a,p);a=(l=!!d)&&"get"in d&&!("originalValue"in d.get)?d.get:a[p]}else l=nr(a,p),a=a[p];l&&!s&&(Yn[i]=a)}}return a},hr={exports:{}};!function(e){var t=Gn,n=pr,r=n("%Function.prototype.apply%"),o=n("%Function.prototype.call%"),i=n("%Reflect.apply%",!0)||t.call(o,r),a=n("%Object.getOwnPropertyDescriptor%",!0),s=n("%Object.defineProperty%",!0),u=n("%Math.max%");if(s)try{s({},"a",{value:1})}catch(e){s=null}e.exports=function(e){var n=i(t,o,arguments);if(a&&s){var r=a(n,"length");r.configurable&&s(n,"length",{value:1+u(0,e.length-(arguments.length-1))})}return n};var c=function(){return i(t,r,arguments)};s?s(e.exports,"apply",{value:c}):e.exports.apply=c}(hr);var fr=pr,dr=hr.exports,yr=dr(fr("String.prototype.indexOf")),gr=l(Object.freeze({__proto__:null,default:{}})),mr="function"==typeof Map&&Map.prototype,vr=Object.getOwnPropertyDescriptor&&mr?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,br=mr&&vr&&"function"==typeof vr.get?vr.get:null,_r=mr&&Map.prototype.forEach,Sr="function"==typeof Set&&Set.prototype,wr=Object.getOwnPropertyDescriptor&&Sr?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Or=Sr&&wr&&"function"==typeof wr.get?wr.get:null,Pr=Sr&&Set.prototype.forEach,Er="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Tr="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ar="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Cr=Boolean.prototype.valueOf,kr=Object.prototype.toString,Nr=Function.prototype.toString,Mr=String.prototype.match,jr=String.prototype.slice,Rr=String.prototype.replace,xr=String.prototype.toUpperCase,Ur=String.prototype.toLowerCase,Ir=RegExp.prototype.test,Dr=Array.prototype.concat,Fr=Array.prototype.join,Gr=Array.prototype.slice,Lr=Math.floor,Kr="function"==typeof BigInt?BigInt.prototype.valueOf:null,Br=Object.getOwnPropertySymbols,Hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,qr="function"==typeof Symbol&&"object"==typeof Symbol.iterator,zr="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===qr||"symbol")?Symbol.toStringTag:null,Vr=Object.prototype.propertyIsEnumerable,Wr=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Jr(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Ir.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Lr(-e):Lr(e);if(r!==e){var o=String(r),i=jr.call(t,o.length+1);return Rr.call(o,n,"$&_")+"."+Rr.call(Rr.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Rr.call(t,n,"$&_")}var $r=gr,Qr=$r.custom,Xr=no(Qr)?Qr:null;function Yr(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function Zr(e){return Rr.call(String(e),/"/g,""")}function eo(e){return!("[object Array]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function to(e){return!("[object RegExp]"!==io(e)||zr&&"object"==typeof e&&zr in e)}function no(e){if(qr)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Hr)return!1;try{return Hr.call(e),!0}catch(e){}return!1}var ro=Object.prototype.hasOwnProperty||function(e){return e in this};function oo(e,t){return ro.call(e,t)}function io(e){return kr.call(e)}function ao(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;nt.maxStringLength){var n=e.length-t.maxStringLength,r="... "+n+" more character"+(n>1?"s":"");return so(jr.call(e,0,t.maxStringLength),t)+r}return Yr(Rr.call(Rr.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uo),"single",t)}function uo(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+xr.call(t.toString(16))}function co(e){return"Object("+e+")"}function lo(e){return e+" { ? }"}function po(e,t,n,r){return e+" ("+t+") {"+(r?ho(n,r):Fr.call(n,", "))+"}"}function ho(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+Fr.call(e,","+n)+"\n"+t.prev}function fo(e,t){var n=eo(e),r=[];if(n){r.length=e.length;for(var o=0;o-1?dr(n):n},mo=function e(t,n,r,o){var i=n||{};if(oo(i,"quoteStyle")&&"single"!==i.quoteStyle&&"double"!==i.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(oo(i,"maxStringLength")&&("number"==typeof i.maxStringLength?i.maxStringLength<0&&i.maxStringLength!==1/0:null!==i.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var a=!oo(i,"customInspect")||i.customInspect;if("boolean"!=typeof a&&"symbol"!==a)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(oo(i,"indent")&&null!==i.indent&&"\t"!==i.indent&&!(parseInt(i.indent,10)===i.indent&&i.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(oo(i,"numericSeparator")&&"boolean"!=typeof i.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var s=i.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return so(t,i);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var u=String(t);return s?Jr(t,u):u}if("bigint"==typeof t){var l=String(t)+"n";return s?Jr(t,l):l}var p=void 0===i.depth?5:i.depth;if(void 0===r&&(r=0),r>=p&&p>0&&"object"==typeof t)return eo(t)?"[Array]":"[Object]";var h=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=Fr.call(Array(e.indent+1)," ")}return{base:n,prev:Fr.call(Array(t+1),n)}}(i,r);if(void 0===o)o=[];else if(ao(o,t)>=0)return"[Circular]";function f(t,n,a){if(n&&(o=Gr.call(o)).push(n),a){var s={depth:i.depth};return oo(i,"quoteStyle")&&(s.quoteStyle=i.quoteStyle),e(t,s,r+1,o)}return e(t,i,r+1,o)}if("function"==typeof t&&!to(t)){var d=function(e){if(e.name)return e.name;var t=Mr.call(Nr.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),y=fo(t,f);return"[Function"+(d?": "+d:" (anonymous)")+"]"+(y.length>0?" { "+Fr.call(y,", ")+" }":"")}if(no(t)){var g=qr?Rr.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Hr.call(t);return"object"!=typeof t||qr?g:co(g)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var m="<"+Ur.call(String(t.nodeName)),v=t.attributes||[],b=0;b"}if(eo(t)){if(0===t.length)return"[]";var _=fo(t,f);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(_)?"["+ho(_,h)+"]":"[ "+Fr.call(_,", ")+" ]"}if(function(e){return!("[object Error]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)){var S=fo(t,f);return"cause"in Error.prototype||!("cause"in t)||Vr.call(t,"cause")?0===S.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Fr.call(S,", ")+" }":"{ ["+String(t)+"] "+Fr.call(Dr.call("[cause]: "+f(t.cause),S),", ")+" }"}if("object"==typeof t&&a){if(Xr&&"function"==typeof t[Xr]&&$r)return $r(t,{depth:p-r});if("symbol"!==a&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!br||!e||"object"!=typeof e)return!1;try{br.call(e);try{Or.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var w=[];return _r&&_r.call(t,(function(e,n){w.push(f(n,t,!0)+" => "+f(e,t))})),po("Map",br.call(t),w,h)}if(function(e){if(!Or||!e||"object"!=typeof e)return!1;try{Or.call(e);try{br.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var O=[];return Pr&&Pr.call(t,(function(e){O.push(f(e,t))})),po("Set",Or.call(t),O,h)}if(function(e){if(!Er||!e||"object"!=typeof e)return!1;try{Er.call(e,Er);try{Tr.call(e,Tr)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return lo("WeakMap");if(function(e){if(!Tr||!e||"object"!=typeof e)return!1;try{Tr.call(e,Tr);try{Er.call(e,Er)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return lo("WeakSet");if(function(e){if(!Ar||!e||"object"!=typeof e)return!1;try{return Ar.call(e),!0}catch(e){}return!1}(t))return lo("WeakRef");if(function(e){return!("[object Number]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Kr)return!1;try{return Kr.call(e),!0}catch(e){}return!1}(t))return co(f(Kr.call(t)));if(function(e){return!("[object Boolean]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(Cr.call(t));if(function(e){return!("[object String]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t))return co(f(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===c)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==io(e)||zr&&"object"==typeof e&&zr in e)}(t)&&!to(t)){var P=fo(t,f),E=Wr?Wr(t)===Object.prototype:t instanceof Object||t.constructor===Object,T=t instanceof Object?"":"null prototype",A=!E&&zr&&Object(t)===t&&zr in t?jr.call(io(t),8,-1):T?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(A||T?"["+Fr.call(Dr.call([],A||[],T||[]),": ")+"] ":"");return 0===P.length?C+"{}":h?C+"{"+ho(P,h)+"}":C+"{ "+Fr.call(P,", ")+" }"}return String(t)},vo=yo("%TypeError%"),bo=yo("%WeakMap%",!0),_o=yo("%Map%",!0),So=go("WeakMap.prototype.get",!0),wo=go("WeakMap.prototype.set",!0),Oo=go("WeakMap.prototype.has",!0),Po=go("Map.prototype.get",!0),Eo=go("Map.prototype.set",!0),To=go("Map.prototype.has",!0),Ao=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n},Co=String.prototype.replace,ko=/%20/g,No="RFC3986",Mo={default:No,formatters:{RFC1738:function(e){return Co.call(e,ko,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:No},jo=Mo,Ro=Object.prototype.hasOwnProperty,xo=Array.isArray,Uo=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Io=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xo(n)){for(var r=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||o===jo.RFC1738&&(40===u||41===u)?a+=i.charAt(s):u<128?a+=Uo[u]:u<2048?a+=Uo[192|u>>6]+Uo[128|63&u]:u<55296||u>=57344?a+=Uo[224|u>>12]+Uo[128|u>>6&63]+Uo[128|63&u]:(s+=1,u=65536+((1023&u)<<10|1023&i.charCodeAt(s)),a+=Uo[240|u>>18]+Uo[128|u>>12&63]+Uo[128|u>>6&63]+Uo[128|63&u])}return a},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(xo(e)){for(var n=[],r=0;r0?v.join(",")||null:void 0}];else if(Ho(u))O=u;else{var E=Object.keys(v);O=c?E.sort(c):E}for(var T=o&&Ho(v)&&1===v.length?n+"[]":n,A=0;A-1?e.split(","):e},ri=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),s=a?o.slice(0,a.index):o,u=[];if(s){if(!n.plainObjects&&Yo.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var c=0;n.depth>0&&null!==(a=i.exec(o))&&c=0;--i){var a,s=e[i];if("[]"===s&&n.parseArrays)a=[].concat(o);else{a=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,c=parseInt(u,10);n.parseArrays||""!==u?!isNaN(c)&&s!==u&&String(c)===u&&c>=0&&n.parseArrays&&c<=n.arrayLimit?(a=[])[c]=o:"__proto__"!==u&&(a[u]=o):a={0:o}}o=a}return o}(u,t,n,r)}},oi=function(e,t){var n,r=e,o=function(e){if(!e)return Jo;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Jo.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Lo.default;if(void 0!==e.format){if(!Ko.call(Lo.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r=Lo.formatters[n],o=Jo.filter;return("function"==typeof e.filter||Ho(e.filter))&&(o=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Jo.addQueryPrefix,allowDots:void 0===e.allowDots?Jo.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Jo.charsetSentinel,delimiter:void 0===e.delimiter?Jo.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Jo.encode,encoder:"function"==typeof e.encoder?e.encoder:Jo.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Jo.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Jo.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Jo.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Jo.strictNullHandling}}(t);"function"==typeof o.filter?r=(0,o.filter)("",r):Ho(o.filter)&&(n=o.filter);var i,a=[];if("object"!=typeof r||null===r)return"";i=t&&t.arrayFormat in Bo?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var s=Bo[i];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u="comma"===s&&t&&t.commaRoundTrip;n||(n=Object.keys(r)),o.sort&&n.sort(o.sort);for(var c=Fo(),l=0;l0?f+h:""},ii={formats:Mo,parse:function(e,t){var n=function(e){if(!e)return ei;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?ei.charset:e.charset;return{allowDots:void 0===e.allowDots?ei.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:ei.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:ei.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:ei.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ei.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:ei.comma,decoder:"function"==typeof e.decoder?e.decoder:ei.decoder,delimiter:"string"==typeof e.delimiter||Xo.isRegExp(e.delimiter)?e.delimiter:ei.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:ei.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:ei.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:ei.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:ei.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ei.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof e?function(e,t){var n,r={__proto__:null},o=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=o.split(t.delimiter,i),s=-1,u=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(l=Zo(l)?[l]:l),Yo.call(r,c)?r[c]=Xo.combine(r[c],l):r[c]=l}return r}(e,n):e,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.split(/ *; */).shift(),e.params=e=>{const n={};var r,o=t(e.split(/ *; */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *= */),t=e.shift(),o=e.shift();t&&o&&(n[t]=o)}}catch(e){o.e(e)}finally{o.f()}return n},e.parseLinks=e=>{const n={};var r,o=t(e.split(/ *, */));try{for(o.s();!(r=o.n()).done;){const e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){o.e(e)}finally{o.f()}return n},e.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),e.isObject=e=>null!==e&&"object"==typeof e,e.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},e.mixin=(t,n)=>{for(const r in n)e.hasOwn(n,r)&&(t[r]=n[r])}}(ai);const si=gr,ui=ai.isObject,ci=ai.hasOwn;var li=pi;function pi(){}pi.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},pi.prototype.parse=function(e){return this._parser=e,this},pi.prototype.responseType=function(e){return this._responseType=e,this},pi.prototype.serialize=function(e){return this._serializer=e,this},pi.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0,this;for(const t in e)if(ci(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}return this},pi.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};const hi=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),fi=new Set([408,413,429,500,502,503,504,521,522,524]);pi.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{const n=this._retryCallback(e,t);if(!0===n)return!0;if(!1===n)return!1}catch(e){console.error(e)}if(t&&t.status&&fi.has(t.status))return!0;if(e){if(e.code&&hi.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}return!1},pi.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},pi.prototype.then=function(e,t){if(!this._fullfilledPromise){const e=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(((t,n)=>{e.on("abort",(()=>{if(this._maxRetries&&this._maxRetries>this._retries)return;if(this.timedout&&this.timedoutError)return void n(this.timedoutError);const e=new Error("Aborted");e.code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)})),e.end(((e,r)=>{e?n(e):t(r)}))}))}return this._fullfilledPromise.then(e,t)},pi.prototype.catch=function(e){return this.then(void 0,e)},pi.prototype.use=function(e){return e(this),this},pi.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},pi.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},pi.prototype.get=function(e){return this._header[e.toLowerCase()]},pi.prototype.getHeader=pi.prototype.get,pi.prototype.set=function(e,t){if(ui(e)){for(const t in e)ci(e,t)&&this.set(t,e[t]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},pi.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},pi.prototype.field=function(e,t,n){if(null==e)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(ui(e)){for(const t in e)ci(e,t)&&this.field(t,e[t]);return this}if(Array.isArray(t)){for(const n in t)ci(t,n)&&this.field(e,t[n]);return this}if(null==t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=String(t)),n?this._getFormData().append(e,t,n):this._getFormData().append(e,t),this},pi.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(si.gte(process.version,"v13.0.0")&&si.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}return this.clearTimeout(),this.emit("abort"),this},pi.prototype._auth=function(e,t,n,r){switch(n.type){case"basic":this.set("Authorization",`Basic ${r(`${e}:${t}`)}`);break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization",`Bearer ${e}`)}return this},pi.prototype.withCredentials=function(e){return void 0===e&&(e=!0),this._withCredentials=e,this},pi.prototype.redirects=function(e){return this._maxRedirects=e,this},pi.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},pi.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},pi.prototype.send=function(e){const t=ui(e);let n=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(t&&ui(this._data))for(const t in e){if("bigint"==typeof e[t]&&!e[t].toJSON)throw new Error("Cannot serialize BigInt value to json");ci(e,t)&&(this._data[t]=e[t])}else{if("bigint"==typeof e)throw new Error("Cannot send value of type BigInt");"string"==typeof e?(n||this.type("form"),n=this._header["content-type"],n&&(n=n.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===n?this._data?`${this._data}&${e}`:e:(this._data||"")+e):this._data=e}return!t||this._isHost(e)||n||this.type("json"),this},pi.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},pi.prototype._finalizeQueryString=function(){const e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){const e=this.url.indexOf("?");if(e>=0){const t=this.url.slice(e+1).split("&");"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}},pi.prototype._appendQueryString=()=>{console.warn("Unsupported")},pi.prototype._timeoutError=function(e,t,n){if(this._aborted)return;const r=new Error(`${e+t}ms exceeded`);r.timeout=t,r.code="ECONNABORTED",r.errno=n,this.timedout=!0,this.timedoutError=r,this.abort(),this.callback(r)},pi.prototype._setTimeouts=function(){const e=this;this._timeout&&!this._timer&&(this._timer=setTimeout((()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")}),this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout((()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")}),this._responseTimeout))};const di=ai;var yi=gi;function gi(){}function mi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){u=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(u)throw a}}}}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{if(o.XMLHttpRequest)return new o.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")};const g="".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,"");function m(e){if(!c(e))return e;const t=[];for(const n in e)p(e,n)&&v(t,n,e[n]);return t.join("&")}function v(e,t,r){if(void 0!==r)if(null!==r)if(Array.isArray(r)){var o,i=n(r);try{for(i.s();!(o=i.n()).done;){v(e,t,o.value)}}catch(e){i.e(e)}finally{i.f()}}else if(c(r))for(const n in r)p(r,n)&&v(e,`${t}[${n}]`,r[n]);else e.push(encodeURI(t)+"="+encodeURIComponent(r));else e.push(encodeURI(t))}function b(e){const t={},n=e.split("&");let r,o;for(let e=0,i=n.length;e{let e,t=null,r=null;try{r=new S(n)}catch(e){return t=new Error("Parser is unable to parse the response"),t.parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status?n.xhr.status:null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)}))}y.serializeObject=m,y.parseString=b,y.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},y.serialize={"application/x-www-form-urlencoded":s.stringify,"application/json":a},y.parse={"application/x-www-form-urlencoded":b,"application/json":JSON.parse},l(S.prototype,h.prototype),S.prototype._parseBody=function(e){let t=y.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&_(this.type)&&(t=y.parse["application/json"]),t&&e&&(e.length>0||e instanceof Object)?t(e):null)},S.prototype.toError=function(){const e=this.req,t=e.method,n=e.url,r=`cannot ${t} ${n} (${this.status})`,o=new Error(r);return o.status=this.status,o.method=t,o.url=n,o},y.Response=S,i(w.prototype),l(w.prototype,u.prototype),w.prototype.type=function(e){return this.set("Content-Type",y.types[e]||e),this},w.prototype.accept=function(e){return this.set("Accept",y.types[e]||e),this},w.prototype.auth=function(e,t,n){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(n=t,t=""),n||(n={type:"function"==typeof btoa?"basic":"auto"});const r=n.encoder?n.encoder:e=>{if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,n,r)},w.prototype.query=function(e){return"string"!=typeof e&&(e=m(e)),e&&this._query.push(e),this},w.prototype.attach=function(e,t,n){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,n||t.name)}return this},w.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},w.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();const n=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),n(e,t)},w.prototype.crossDomainError=function(){const e=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},w.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},w.prototype.ca=w.prototype.agent,w.prototype.buffer=w.prototype.ca,w.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},w.prototype.pipe=w.prototype.write,w.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},w.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||d,this._finalizeQueryString(),this._end()},w.prototype._setUploadTimeout=function(){const e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout((()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")}),this._uploadTimeout))},w.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));const e=this;this.xhr=y.getXHR();const t=this.xhr;let n=this._formData||this._data;this._setTimeouts(),t.addEventListener("readystatechange",(()=>{const n=t.readyState;if(n>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4!==n)return;let r;try{r=t.status}catch(e){r=0}if(!r){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}));const r=(t,n)=>{n.total>0&&(n.percent=n.loaded/n.total*100,100===n.percent&&clearTimeout(e._uploadTimeoutTimer)),n.direction=t,e.emit("progress",n)};if(this.hasListeners("progress"))try{t.addEventListener("progress",r.bind(null,"download")),t.upload&&t.upload.addEventListener("progress",r.bind(null,"upload"))}catch(e){}t.upload&&this._setUploadTimeout();try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof n&&!this._isHost(n)){const e=this._header["content-type"];let t=this._serializer||y.serialize[e?e.split(";")[0]:""];!t&&_(e)&&(t=y.serialize["application/json"]),t&&(n=t(n))}for(const e in this.header)null!==this.header[e]&&p(this.header,e)&&t.setRequestHeader(e,this.header[e]);this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0===n?null:n)},y.agent=()=>new f;for(var O=0,P=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];O{const r=y("GET",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.head=(e,t,n)=>{const r=y("HEAD",e);return"function"==typeof t&&(n=t,t=null),t&&r.query(t),n&&r.end(n),r},y.options=(e,t,n)=>{const r=y("OPTIONS",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.del=E,y.delete=E,y.patch=(e,t,n)=>{const r=y("PATCH",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.post=(e,t,n)=>{const r=y("POST",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r},y.put=(e,t,n)=>{const r=y("PUT",e);return"function"==typeof t&&(n=t,t=null),t&&r.send(t),n&&r.end(n),r}}(gn,gn.exports);var Oi=gn.exports;function Pi(e){var t=(new Date).getTime(),n=(new Date).toISOString(),r=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;r.log("<<<<<"),r.log("[".concat(n,"]"),"\n",e.url,"\n",e.qs),r.log("-----"),e.on("response",(function(n){var o=(new Date).getTime()-t,i=(new Date).toISOString();r.log(">>>>>>"),r.log("[".concat(i," / ").concat(o,"]"),"\n",e.url,"\n",e.qs,"\n",n.text),r.log("-----")}))}function Ei(e,t,n){var r=this;this._config.logVerbosity&&(e=e.use(Pi)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),this._config.keepAlive&&this._modules.keepAlive&&(e=this._modules.keepAlive(e));var o=e;if(t.abortSignal)var i=t.abortSignal.subscribe((function(){o.abort(),i()}));return!0===t.forceBuffered?o="undefined"==typeof Blob?o.buffer().responseType("arraybuffer"):o.responseType("arraybuffer"):!1===t.forceBuffered&&(o=o.buffer(!1)),(o=o.timeout(t.timeout)).on("abort",(function(){return n({category:R.PNUnknownCategory,error:!0,operation:t.operation,errorData:new Error("Aborted")},null)})),o.end((function(e,o){var i,a={};if(a.error=null!==e,a.operation=t.operation,o&&o.status&&(a.statusCode=o.status),e){if(e.response&&e.response.text&&!r._config.logVerbosity)try{a.errorData=JSON.parse(e.response.text)}catch(t){a.errorData=e}else a.errorData=e;return a.category=r._detectErrorCategory(e),n(a,null)}if(t.ignoreBody)i={headers:o.headers,redirects:o.redirects,response:o};else try{i=JSON.parse(o.text)}catch(e){return a.errorData=o,a.error=!0,n(a,null)}return i.error&&1===i.error&&i.status&&i.message&&i.service?(a.errorData=i,a.statusCode=i.status,a.error=!0,a.category=r._detectErrorCategory(a),n(a,null)):(i.error&&i.error.message&&(a.errorData=i.error),n(a,i))})),o}function Ti(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=Oi.post(e),t.forEach((function(e){var t=e.key,n=e.value;r=r.field(t,n)})),r.attach("file",n,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,o.sent()]}}))}))}function Ai(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function Ci(e,t,n){var r=Oi.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ki(e,t,n,r){var o=Oi.post(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Ni(e,t,n,r){var o=Oi.patch(this.getStandardOrigin()+n.url).query(e).set(n.headers).send(t);return Ei.call(this,o,n,r)}function Mi(e,t,n){var r=Oi.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return Ei.call(this,r,t,n)}function ji(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}var Ri,xi=function(){function e(){}return Object.defineProperty(e.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.encryptString(n,t)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}}))}))},e.prototype.decrypt=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.getKey(e)];case 1:if(n=r.sent(),t instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(n,t)];if("string"==typeof t)return[2,this.decryptString(n,t)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}}))}))},e.prototype.encryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:if(t.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.encryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,mimeType:"application/octet-stream",data:a})]}}))}))},e.prototype.decryptFile=function(e,t,n){return o(this,void 0,void 0,(function(){var r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,this.getKey(e)];case 1:return r=i.sent(),[4,t.data.arrayBuffer()];case 2:return o=i.sent(),[4,this.decryptArrayBuffer(r,o)];case 3:return a=i.sent(),[2,n.create({name:t.name,data:a})]}}))}))},e.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return[4,crypto.subtle.digest("SHA-256",e.encoder.encode(t))];case 1:return n=i.sent(),r=Array.from(new Uint8Array(n)).map((function(e){return e.toString(16).padStart(2,"0")})).join(""),o=e.encoder.encode(r.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",o,"AES-CBC",!0,["encrypt","decrypt"])]}}))}))},e.prototype.encryptArrayBuffer=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=crypto.getRandomValues(new Uint8Array(16)),r=ji,o=[n.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:n},e,t)];case 1:return[2,r.apply(void 0,o.concat([i.sent()]))]}}))}))},e.prototype.decryptArrayBuffer=function(t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:if(r=n.slice(0,16),n.slice(e.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},t,n.slice(e.IV_LENGTH))];case 1:return[2,o.sent()]}}))}))},e.prototype.encryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),o=e.encoder.encode(n).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:r},t,o)];case 1:return a=i.sent(),s=ji(r.buffer,a),[2,e.decoder.decode(s)]}}))}))},e.prototype.decryptString=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s;return i(this,(function(i){switch(i.label){case 0:return r=e.encoder.encode(n).buffer,o=r.slice(0,16),a=r.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:o},t,a)];case 1:return s=i.sent(),[2,e.decoder.decode(s)]}}))}))},e.IV_LENGTH=16,e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Ui=(Ri=function(){function e(e){if(e instanceof File)this.data=e,this.name=this.data.name,this.mimeType=this.data.type;else if(e.data){var t=e.data;this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType&&(this.mimeType=e.mimeType)}if(void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}return e.create=function(e){return new this(e)},e.prototype.toBuffer=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toStream=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in Node.js environments.")}))}))},e.prototype.toFileUri=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){throw new Error("This feature is only supported in react native environments.")}))}))},e.prototype.toBlob=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e.prototype.toArrayBuffer=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if(r.result instanceof ArrayBuffer)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsArrayBuffer(e.data)}))]}))}))},e.prototype.toString=function(){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){if("string"==typeof r.result)return t(r.result)})),r.addEventListener("error",(function(){n(r.error)})),r.readAsBinaryString(e.data)}))]}))}))},e.prototype.toFile=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.data]}))}))},e}(),Ri.supportsFile="undefined"!=typeof File,Ri.supportsBlob="undefined"!=typeof Blob,Ri.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,Ri.supportsBuffer=!1,Ri.supportsStream=!1,Ri.supportsString=!0,Ri.supportsEncryptFile=!0,Ri.supportsFileUri=!1,Ri),Ii=function(){function e(e){this.config=e,this.cryptor=new A({config:e}),this.fileCryptor=new xi}return Object.defineProperty(e.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),e.prototype.encrypt=function(e){var t="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(t),metadata:null}},e.prototype.decrypt=function(e){var t="string"==typeof e.data?e.data:v(e.data);return this.cryptor.decrypt(t)},e.prototype.encryptFile=function(e,t){var n;return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.fileCryptor.encryptFile(null===(n=this.config)||void 0===n?void 0:n.cipherKey,e,t)]}))}))},e.prototype.decryptFile=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,e,t)]}))}))},e}(),Di=function(){function e(e){this.cipherKey=e.cipherKey,this.CryptoJS=E,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}return Object.defineProperty(e.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),e.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(e.BLOCK_SIZE))},e.prototype.getKey=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(r){switch(r.label){case 0:return t=e.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return n=r.sent(),[2,crypto.subtle.importKey("raw",n,this.algo,!0,["encrypt","decrypt"])]}}))}))},e.prototype.encrypt=function(t){if(0===("string"==typeof t?t:e.decoder.decode(t)).length)throw new Error("encryption error. empty content");var n=this.getIv();return{metadata:n,data:m(this.CryptoJS.AES.encrypt(t,this.encryptedKey,{iv:this.bufferToWordArray(n),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},e.prototype.decrypt=function(t){var n=this.bufferToWordArray(new Uint8ClampedArray(t.metadata)),r=this.bufferToWordArray(new Uint8ClampedArray(t.data));return e.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:r},this.encryptedKey,{iv:n,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},e.prototype.encryptFileData=function(e){return o(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(o){switch(o.label){case 0:return[4,this.getKey()];case 1:return t=o.sent(),n=this.getIv(),r={},[4,crypto.subtle.encrypt({name:this.algo,iv:n},t,e)];case 2:return[2,(r.data=o.sent(),r.metadata=n,r)]}}))}))},e.prototype.decryptFileData=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getKey()];case 1:return t=n.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:e.metadata},t,e.data)]}}))}))},e.prototype.bufferToWordArray=function(e){var t,n=[];for(t=0;t0?t.slice(n.length-n.metadataLength,n.length):null;if(t.slice(n.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:t.slice(n.length),metadata:o})},e.prototype.encryptFile=function(e,t){return o(this,void 0,void 0,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return this.defaultCryptor.identifier===Gi.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(e,t)]:[4,this.getFileData(e.data)];case 1:return n=o.sent(),[4,this.defaultCryptor.encryptFileData(n)];case 2:return r=o.sent(),[2,t.create({name:e.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(r),r.data)})]}}))}))},e.prototype.decryptFile=function(t,n){return o(this,void 0,void 0,(function(){var r,o,a,s,u,c,l,p;return i(this,(function(i){switch(i.label){case 0:return[4,t.data.arrayBuffer()];case 1:return r=i.sent(),o=Gi.tryParse(r),(null==(a=this.getCryptor(o))?void 0:a.identifier)===e.LEGACY_IDENTIFIER?[2,a.decryptFile(t,n)]:[4,this.getFileData(r)];case 2:return s=i.sent(),u=s.slice(o.length-o.metadataLength,o.length),l=(c=n).create,p={name:t.name},[4,this.defaultCryptor.decryptFileData({data:r.slice(o.length),metadata:u})];case 3:return[2,l.apply(c,[(p.data=i.sent(),p)])]}}))}))},e.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find((function(e){return""===e.identifier}));if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Li)return this.getCryptorFromId(e.identifier)},e.prototype.getCryptorFromId=function(e){var t=this.getAllCryptors().find((function(t){return e===t.identifier}));if(t)return t;throw Error("unknown cryptor error")},e.prototype.concatArrayBuffer=function(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer},e.prototype.getHeaderData=function(e){if(e.metadata){var t=Gi.from(this.defaultCryptor.identifier,e.metadata),n=new Uint8Array(t.length),r=0;return n.set(t.data,r),r+=t.length-e.metadata.byteLength,n.set(new Uint8Array(e.metadata),r),n.buffer}},e.prototype.getFileData=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,n.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,e.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}}))}))},e.LEGACY_IDENTIFIER="",e.encoder=new TextEncoder,e.decoder=new TextDecoder,e}(),Gi=function(){function e(){}return e.from=function(t,n){if(t!==e.LEGACY_IDENTIFIER)return new Li(t,n.byteLength)},e.tryParse=function(t){var n=new Uint8Array(t),r="";if(n.byteLength>=4&&(r=n.slice(0,4),this.decoder.decode(r)!==e.SENTINEL))return"";if(!(n.byteLength>=5))throw new Error("decryption error. invalid header version");if(n[4]>e.MAX_VERSION)throw new Error("unknown cryptor error");var o="",i=5+e.IDENTIFIER_LENGTH;if(!(n.byteLength>=i))throw new Error("decryption error. invalid crypto identifier");o=n.slice(5,i);var a=null;if(!(n.byteLength>=i+1))throw new Error("decryption error. invalid metadata length");return a=n[i],i+=1,255===a&&n.byteLength>=i+2&&(a=new Uint16Array(n.slice(i,i+2)).reduce((function(e,t){return(e<<8)+t}),0),i+=2),new Li(this.decoder.decode(o),a)},e.SENTINEL="PNED",e.LEGACY_IDENTIFIER="",e.IDENTIFIER_LENGTH=4,e.VERSION=1,e.MAX_VERSION=1,e.decoder=new TextDecoder,e}(),Li=function(){function e(e,t){this._identifier=e,this._metadataLength=t}return Object.defineProperty(e.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return Gi.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return Gi.SENTINEL.length+1+Gi.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),n=new TextEncoder;t.set(n.encode(Gi.SENTINEL)),t[e+=Gi.SENTINEL.length]=this.version,e++,this.identifier&&t.set(n.encode(this.identifier),e),e+=Gi.IDENTIFIER_LENGTH;var r=this.metadataLength;return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),e.IDENTIFIER_LENGTH=4,e.SENTINEL="PNED",e}();function Ki(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var Bi=function(e){function n(t){var n=this,r=t.listenToBrowserNetworkEvents,o=void 0===r||r;return t.sdkFamily="Web",t.networking=new fn({del:Mi,get:Ci,post:ki,patch:Ni,sendBeacon:Ki,getfile:Ai,postfile:Ti}),t.cbor=new yn((function(e){return dn(h.decode(e))}),m),t.PubNubFile=Ui,t.cryptography=new xi,t.initCryptoModule=function(e){return new Fi({default:new Ii({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Di({cipherKey:e.cipherKey})]})},n=e.call(this,t)||this,o&&(window.addEventListener("offline",(function(){n.networkDownDetected()})),window.addEventListener("online",(function(){n.networkUpDetected()}))),n}return t(n,e),n.CryptoModule=Fi,n}(hn);return Bi})); diff --git a/lib/core/components/config.js b/lib/core/components/config.js index c155e65fe..f6dcceb4e 100644 --- a/lib/core/components/config.js +++ b/lib/core/components/config.js @@ -180,7 +180,7 @@ var default_1 = /** @class */ (function () { return this; }; default_1.prototype.getVersion = function () { - return '7.4.5'; + return '7.5.0'; }; default_1.prototype._setRetryConfiguration = function (configuration) { if (configuration.minimumdelay < 2) { diff --git a/lib/core/components/push_payload.js b/lib/core/components/push_payload.js index 5885061cf..a35eb6aeb 100644 --- a/lib/core/components/push_payload.js +++ b/lib/core/components/push_payload.js @@ -1,4 +1,6 @@ "use strict"; +/* */ +/* eslint max-classes-per-file: ["error", 5] */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || diff --git a/lib/core/endpoints/access_manager/grant.js b/lib/core/endpoints/access_manager/grant.js index f97ec610b..e65a390b5 100644 --- a/lib/core/endpoints/access_manager/grant.js +++ b/lib/core/endpoints/access_manager/grant.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); function getOperation() { return operations_1.default.PNAccessManagerGrant; diff --git a/lib/core/endpoints/actions/get_message_actions.js b/lib/core/endpoints/actions/get_message_actions.js index 8d2766ff5..669face9a 100644 --- a/lib/core/endpoints/actions/get_message_actions.js +++ b/lib/core/endpoints/actions/get_message_actions.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); var utils_1 = __importDefault(require("../../utils")); function getOperation() { diff --git a/lib/core/endpoints/channel_groups/add_channels.js b/lib/core/endpoints/channel_groups/add_channels.js index ed3ac033b..7c7426e5b 100644 --- a/lib/core/endpoints/channel_groups/add_channels.js +++ b/lib/core/endpoints/channel_groups/add_channels.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); var utils_1 = __importDefault(require("../../utils")); function getOperation() { diff --git a/lib/core/endpoints/channel_groups/list_channels.js b/lib/core/endpoints/channel_groups/list_channels.js index 2b9115e1a..6e385eec4 100644 --- a/lib/core/endpoints/channel_groups/list_channels.js +++ b/lib/core/endpoints/channel_groups/list_channels.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); var utils_1 = __importDefault(require("../../utils")); function getOperation() { diff --git a/lib/core/endpoints/channel_groups/remove_channels.js b/lib/core/endpoints/channel_groups/remove_channels.js index d99f2d27b..74aa55bcf 100644 --- a/lib/core/endpoints/channel_groups/remove_channels.js +++ b/lib/core/endpoints/channel_groups/remove_channels.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); var utils_1 = __importDefault(require("../../utils")); function getOperation() { diff --git a/lib/core/endpoints/fetch_messages.js b/lib/core/endpoints/fetch_messages.js index 364e6b698..ba1c5e7ec 100644 --- a/lib/core/endpoints/fetch_messages.js +++ b/lib/core/endpoints/fetch_messages.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../constants/operations")); var utils_1 = __importDefault(require("../utils")); function __processMessage(modules, message) { diff --git a/lib/core/endpoints/history/get_history.js b/lib/core/endpoints/history/get_history.js index 25b636160..5cbc72ad3 100644 --- a/lib/core/endpoints/history/get_history.js +++ b/lib/core/endpoints/history/get_history.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); var utils_1 = __importDefault(require("../../utils")); function __processMessage(modules, message) { diff --git a/lib/core/endpoints/presence/here_now.js b/lib/core/endpoints/presence/here_now.js index aa9a1dbc5..87cbd46e4 100644 --- a/lib/core/endpoints/presence/here_now.js +++ b/lib/core/endpoints/presence/here_now.js @@ -1,5 +1,4 @@ "use strict"; -/* */ var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -16,6 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleError = exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); var utils_1 = __importDefault(require("../../utils")); function getOperation() { diff --git a/lib/core/endpoints/presence/where_now.js b/lib/core/endpoints/presence/where_now.js index d19cf302a..05c069125 100644 --- a/lib/core/endpoints/presence/where_now.js +++ b/lib/core/endpoints/presence/where_now.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); var utils_1 = __importDefault(require("../../utils")); function getOperation() { diff --git a/lib/core/endpoints/publish.js b/lib/core/endpoints/publish.js index 6799ecc64..f4d3dbafc 100644 --- a/lib/core/endpoints/publish.js +++ b/lib/core/endpoints/publish.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.postPayload = exports.isAuthSupported = exports.getRequestTimeout = exports.postURL = exports.getURL = exports.usePost = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../constants/operations")); var utils_1 = __importDefault(require("../utils")); var base64_codec_1 = require("../components/base64_codec"); diff --git a/lib/core/endpoints/push/list_push_channels.js b/lib/core/endpoints/push/list_push_channels.js index 343c3a7a7..304662c2c 100644 --- a/lib/core/endpoints/push/list_push_channels.js +++ b/lib/core/endpoints/push/list_push_channels.js @@ -1,5 +1,4 @@ "use strict"; -/* */ var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { @@ -16,6 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../../constants/operations")); function getOperation() { return operations_1.default.PNPushNotificationEnabledChannelsOperation; diff --git a/lib/core/endpoints/subscribe.js b/lib/core/endpoints/subscribe.js index dd9cc98e3..702295738 100644 --- a/lib/core/endpoints/subscribe.js +++ b/lib/core/endpoints/subscribe.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleResponse = exports.prepareParams = exports.isAuthSupported = exports.getRequestTimeout = exports.getURL = exports.validateParams = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../constants/operations")); var utils_1 = __importDefault(require("../utils")); function getOperation() { diff --git a/lib/core/endpoints/time.js b/lib/core/endpoints/time.js index 198455ddf..8673d0a95 100644 --- a/lib/core/endpoints/time.js +++ b/lib/core/endpoints/time.js @@ -1,10 +1,10 @@ "use strict"; -/* */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateParams = exports.handleResponse = exports.isAuthSupported = exports.prepareParams = exports.getRequestTimeout = exports.getURL = exports.getOperation = void 0; +/* */ var operations_1 = __importDefault(require("../constants/operations")); function getOperation() { return operations_1.default.PNTimeOperation; diff --git a/package.json b/package.json index 6560cc58a..82ffad741 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pubnub", - "version": "7.4.5", + "version": "7.5.0", "author": "PubNub ", "description": "Publish & Subscribe Real-time Messaging with PubNub", "scripts": { diff --git a/src/core/components/config.js b/src/core/components/config.js index 395086a45..ab9050acc 100644 --- a/src/core/components/config.js +++ b/src/core/components/config.js @@ -358,7 +358,7 @@ export default class { } getVersion() { - return '7.4.5'; + return '7.5.0'; } _setRetryConfiguration(configuration) {